Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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);

}
}
 
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
What's stopping you from running the code and checking the output by yourself?
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Almost similar to https://coderanch.com/t/566150/java/java/want-know-benefit-reference-variable
Let us continue the discussion there
 
    Bookmark Topic Watch Topic
  • New Topic