aspose file tools*
The moose likes Beginning Java and the fly likes Simple Program but what's wrong??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Simple Program but what Watch "Simple Program but what New topic
Author

Simple Program but what's wrong???

James Hambrick
Ranch Hand

Joined: Sep 04, 2004
Posts: 282



I get the value 0 when its ran, not 2. Why???


Visit my blog! http://jameshambrick.com
James Hambrick
Ranch Hand

Joined: Sep 04, 2004
Posts: 282


I know that this works correctly, but why does it not work the other way???
Bob Ruth
Ranch Hand

Joined: Jun 04, 2007
Posts: 320
Happy to help!

Your problem boils down to one major "oops". In your class method that changes the color.... take a look... a CLOSE look at exactly WHAT is getting set with the value of what! Hint.... you are setting the value of the argument with the current value of the int. To research this part, look up some info on "assignment" and I think you'll find the key.

The reason that it works in the second example is that, in the same handler as above, you are returning the value of the argument that you passed in NOT the value of the int. It will always pass back what you passed in.

Read this, take another look at these areas, and I think you'll find your answer!

Best of luck.


------------------------
Bob
SCJP - 86% - June 11, 2009
Garrett Rowe
Ranch Hand

Joined: Jan 17, 2006
Posts: 1296

Says, assign the current value of the variable anIntegerRepresentingColors to the variable newHue and then allow the newHue variable to fall out of scope.

What I think you want is:



Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
James Hambrick
Ranch Hand

Joined: Sep 04, 2004
Posts: 282

how about that, it works now. thanks I overlooked that.
Bob Ruth
Ranch Hand

Joined: Jun 04, 2007
Posts: 320
My pleasure.
 
Consider Paul's rocket mass heater.
 
subject: Simple Program but what's wrong???