This blog is for everyone who want to learn Java as well as want quick refresh of Java. This is really easy manner to learn something in easy way, whole blog is explained in very simple language so that even the person who don't know anything about Java can understand it.
Sunday, November 10, 2013
Use of "this" keyword with very simple example
class thiss{
int a,b;
thiss(){
a=1;
b=2;}
thiss(int c,int d){
this();
this.a=c;
this.b=d;
}
void displaydata(){
System.out.println("c= "+a);
System.out.println("d= "+b);
}
public static void main(String []arg){
thiss t1= new thiss();
t1.displaydata();
thiss t2= new thiss(3,4);
t2.displaydata();
}}
___________________
Output:
c= 1;
d=2;
c= 3;
d=4;
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment