Skip to content

Instantly share code, notes, and snippets.

View anjanashankar9's full-sized avatar

Anjana Shankar anjanashankar9

View GitHub Profile
public static List watchedGetChildren(CuratorFramework client, String path) throws Exception {
return client.getChildren()
.usingWatcher(new WatcherImpl(client,path))
.forPath(path);
}
public static String getData(CuratorFramework client, String path) throws Exception{
String str = new String(client.getData()
.usingWatcher(new WatcherImpl(client,path))
.forPath(path));
return str;
}
public class WatcherImpl implements Watcher{
@Override
public void process(WatchedEvent event) {
if(event.getType() == Event.EventType.NodeDataChanged) {
System.out.println("The Data has changed");
}
else if(event.getType() == Event.EventType.NodeChildrenChanged){
System.out.println("Children have changed");
}
}
class A {
//Constructor of A
A() {
System.out.println("A's constructor");
}
public void method() {
System.out.println("A's get method");
}
}
class B extends A{
//Constructor of B
B(){
System.out.println("B's constructor");
}
}
public static void main(String[] args) {
System.out.println("JAVA - INHERITANCE");
B objectB = new B();
}
JAVA - INHERITANCE
A's constructor
B's constructor
class B extends A{
//Constructor of B
B(){
System.out.println("B's constructor"); //This is not allowed
super();
}
}
class B extends A{
//Constructor of B
B(){
super();
}
}
class B extends A{
//Constructor of B
B(){
super();
}
@Override
public void method(){
System.out.println("B's get method");
super.method();