Hello Guys :D Why can't I execute the following code withoud getting a runtime exception? How should it be rewritten? I am migrating from C++ where I could easily do that I suppose :D.
class MyJavaClass {
public static void main(String args[]) {
Dog bushui_RIP = new Dog();
Dog fellow = null;
bushui_RIP.bark(fellow);
fellow.bark();
}
}
class Dog {
public void bark(Dog buddy) {
buddy = this;
}
public void bark() {
System.out.println("I am barking!!!");
}
}