Sunday 16 December 2012

Contructor Output

 
class MyClass{
 
int x=100;
int y=200;
 
void MyClass(){
System.out.print(x+" ");
System.out.print(y+" ");
x=30;
y=40;
}
}
class Demo{
public static void main (String []args){
MyClass c=new MyClass();
System.out.print(c.x+" ");
System.out.print(c.y+" ");
}
}
 
Thus this is function void MyClass to declare constructor we should not use void .

No comments:

Post a Comment