wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Can someone tell me why? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Can someone tell me why?" Watch "Can someone tell me why?" New topic
Author

Can someone tell me why?

marcus conway
Greenhorn

Joined: Oct 30, 2008
Posts: 12
Hello,

Can someone tell me why--after i create a cube--it display 'enter test operation' twice?



[ November 17, 2008: Message edited by: Bear Bibeault ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41134
    
  45
That's in a loop, so I'd assume that the loop is executed repeatedly. Check whether the loop termination condition works as you expect it to.

By the way, I'm almost positive that the getValue method does not work as you expect it to work. You may want to read about the "switch" statement, and what happens once one of the cases is matched.

Lastly, in the future UseAMeaningfulSubjectLine that states what the problem is.
[ November 17, 2008: Message edited by: Ulf Dittmer ]

Ping & DNS - my free Android networking tools app
marcus conway
Greenhorn

Joined: Oct 30, 2008
Posts: 12
Originally posted by Ulf Dittmer:
That's in a loop, so I'd assume that the loop is executed repeatedly. Check whether the loop termination condition works as you expect it to.

By the way, I'm almost positive that the getValue method does not work as you expect it to work. You may want to read about the "switch" statement, and what happens once one of the cases is matched.

Lastly, in the future UseAMeaningfulSubjectLine that states what the problem is.

[ November 17, 2008: Message edited by: Ulf Dittmer ]


Is it because I'm using the getValue() switch statement on chars?

Thanks for your help
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41134
    
  45
No, chars work fine in switch statements. Ask yourself this: Suppose getFace() returns 't', causing "val = 1;" to be executed. Now, what is the next statement that gets executed? And consequently, which value of "val" will be returned from the method?
marcus conway
Greenhorn

Joined: Oct 30, 2008
Posts: 12
Originally posted by Ulf Dittmer:
No, chars work fine in switch statements. Ask yourself this: Suppose getFace() returns 't', causing "val = 1;" to be executed. Now, what is the next statement that gets executed? And consequently, which value of "val" will be returned from the method?


how bout this?
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3432
    
  12
I think Ulf was hinting you should read about the break keyword in a switch statement


Joanne
Bill Shirley
Ranch Hand

Joined: Nov 08, 2007
Posts: 457
FAQ: Use A Meaningful Subject Line

welcome,

history note:
the good ol' switch statement comes down to us from the C programming language, the first step up from assembly programming, and as such still requires a little bit more work to do what you want it to,

(i.e. check on the break keyword as suggested above - and/or trace through the debugger and see how it's executing)
[ November 17, 2008: Message edited by: Bill Shirley ]

Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can someone tell me why?
 
Similar Threads
how many objects will be eligible for garbage collection
Garbage collection doubt
Number of Objects eligible for Garbage Collection
Method Parameter/Argument Question
how to write the game-CrossingRiver (2)