Bookmark Topic Watch Topic
  • New Topic

What is the purpose of code Emp e2=e1; and what is the benefit of this. Give output also of the prog  RSS feed

 
Neeraj Goyal
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Report post to moderator
class Emp
{
String name;
int salary;
void get(String s1,int s2)
{
name=s1;
salary=s2;
}
void show()
{
System.out.println(name);
System.out.println(salary);
}

public static void main(String... s)
{
Emp e1=new Emp();
e1.get("neeraj",20000);
e1.show();
Emp e2=e1;
e2.show();
e2.get("vikram",2000);

}
}
 
Soumyajit Hazra
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Report post to moderator
What's stopping you from running the code and checking the output by yourself?
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
 
It is sorta covered in the JavaRanch Style Guide.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!