• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Without using THIS operator

 
Praveen Ramachandran
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class A {
public A(){
System.out.println(this + ": Called me");
}
}

public class B extends A {
public B(){

}
}


public class C extends A {
public C() {

}
}


public class D {

/**
* @param args
*/
public static void main(String[] args) {
A a1 = new A();
B b1 = new B();
C c1 = new C();
}

}


This program would simply print the object which called it..
Can we do this w/o using 'this' operator.Please let me know
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following code does exactly the same as your code but without using the "this" keyword:
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic