Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

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;



This post first appeared on LET's START CORE JAVA !, please read the originial post: here

Share the post

Use of "this" keyword with very simple example

×

Subscribe to Let's Start Core Java !

Get updates delivered right to your inbox!

Thank you for your subscription

×