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 Question about variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Question about variables" Watch "Question about variables" New topic
Author

Question about variables

Ameem Shaik
Greenhorn

Joined: May 24, 2010
Posts: 4
Hi, I need clarification about why these two scenarios produce different type of results.
When you have something like:


y=3, not 7.

However, when you have something like this:


a.size =20, not 10.

What causes this difference? I'm guessing it has to do something with the difference in primitive variables and object reference variables, but I'm not entirely sure. I'm new to both Java and programming in general, so can someone explain this to me? Thanks.

Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

Hi,

Welcome to JavaRanch!

Read this and then this and I guarantee you will understand perfectly!


[Jess in Action][AskingGoodQuestions]
Jim Hoglund
Ranch Hand

Joined: Jan 09, 2008
Posts: 525
Hi Ameem : Welcome to the ranch. With just a quick look you'll see
that you created just one object with new, but with two reference
variables for it. So you can use either variable to change the object's
state or to look at it.

Jim ... ...


BEE MBA PMP SCJP-6
Ameem Shaik
Greenhorn

Joined: May 24, 2010
Posts: 4
Thank you both for the help! It is now clear to me.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question about variables
 
Similar Threads
how the program works?
Illegal start of expression compilation error
++ and --
how to compare the values in arrays
Dog is not abstract and does not override abstract method