| Author |
What is the purpose of code Emp e2=e1; and what is the benefit of this. Give output also of the prog
|
Neeraj Goyal
Greenhorn
Joined: Feb 01, 2012
Posts: 2
|
posted

0
|
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
Joined: Jun 26, 2007
Posts: 135
|
posted

0
|
|
What's stopping you from running the code and checking the output by yourself?
|
Java Programmer | SCJP 1.5 | SCWCD 1.4
|
 |
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 7602
|
posted

0
|
Almost similar to http://www.coderanch.com/t/566150/java/java/want-know-benefit-reference-variable
Let us continue the discussion there
|
[Donate a pint, save a life!] [How to ask questions]
|
 |
 |
|
|
subject: What is the purpose of code Emp e2=e1; and what is the benefit of this. Give output also of the prog
|
|
|