class Twelve{
int x=3;
void increment(int a)
{
System.out.println("Value of a before increment: "+a);
a=a+1;
System.out.println("Value of a after increment: "+a);
}
public static void main(String args[])
{
Twelve op=new Twelve();
System.out.println("Value of x before calling increment(): "+op.x);
op.increment(4);
System.out.println("Value of x after calling increment(): "+op.x);
}
}
int x=3;
void increment(int a)
{
System.out.println("Value of a before increment: "+a);
a=a+1;
System.out.println("Value of a after increment: "+a);
}
public static void main(String args[])
{
Twelve op=new Twelve();
System.out.println("Value of x before calling increment(): "+op.x);
op.increment(4);
System.out.println("Value of x after calling increment(): "+op.x);
}
}
No comments:
Post a Comment