File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes want to know the benefit of using reference variable like Emp e2=e1 Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "want to know the benefit of using reference variable like Emp e2=e1" Watch "want to know the benefit of using reference variable like Emp e2=e1" New topic
Author

want to know the benefit of using reference variable like Emp e2=e1

Neeraj Goyal
Greenhorn

Joined: Feb 01, 2012
Posts: 2
problem is that i have used Emp e2=e1; e1 and e2 are the reference variables. and just passing e1 into e2 and accesing the functions by e2 reference variable. Just want to know what is the benefit of accesing by using Emp e2=e1.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 7602

Welcome to the Ranch.

In future, please CarefullyChooseOneForum I have moved your posts from the JNLP forum because they are not related to JNLP.
I have also closed the other post, which was almost similar to this one.


[Donate a pint, save a life!] [How to ask questions]
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 3141
Neeraj Goyal wrote:problem is that i have used Emp e2=e1; e1 and e2 are the reference variables. and just passing e1 into e2 and accesing the functions by e2 reference variable. Just want to know what is the benefit of accesing by using Emp e2=e1.


All by itself, that's pointless. But maybe you have a situation like this:



In this case, we want to do something with a particular Emp object, but we have to pick which one based on some condition. So we use a separate variable for a copy of the reference to the object we're interested in. If we didn't do that, we'd have to either duplicate all the code that uses e3 into both if and else, making sure to change the variable names after copy/pasting.
 
 
subject: want to know the benefit of using reference variable like Emp e2=e1
 
Threads others viewed
writing a class object in session variable in jsp
find second largest value in a column
using aliases
sorting table columns
problem accesing the servlet
MyEclipse, The Clear Choice

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture