Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

doubt in chapter 3 k&B book  RSS feed

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is from K&B book. Chapter 3.

Could you please explain how come f1.x==f3.x returns true, because f1.x prints 5 and f3.x prints 6.

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Cathymala:

Remember that when you are passing objects as arguments, you are passing it by reference, so in the FizzSwitch method, you have the x, and z Fizz variables are refering to the same object, so if you are modifying the values in z or even x, you also are modifying the values in f1. Check this printing the value of f1.x before the f1==f3 statement.

Regards,

Alejandro Galvan

--------------------

Preparing SCJP
 
cathymala louis
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ..
Check out this post .It should surely help! ...

Thanks
 
sweta doshi
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ..
Check out this post .It should surely help! ...
http://www.coderanch.com/t/266948/java-programmer-SCJP/certification/help


Thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!