Results 1 to 2 of 2
Thread: Newbie Question - Switch
- 07-16-2011, 02:29 AM #1
Member
- Join Date
- Jul 2011
- Posts
- 1
- Rep Power
- 0
Newbie Question - Switch
Hey, just wondering if anybody could help me out here.
Little bit of example code:
What i'm looking to do is print a message such as "No action performed" (as an example) if none of the cases matched the random number. Is there an easy way to do this?Java Code:private void numberGen() { int x = Random.nextInt(1,30); switch (x) { case 10: (Do some action); break; case 20: (Do some action); break; case 30: (Do some action); break; } }
Thanks.Last edited by R0bert0; 07-16-2011 at 02:36 AM.
- 07-16-2011, 04:19 AM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,545
- Rep Power
- 11
Similar Threads
-
Probably a newbie question.... :P
By gblax123 in forum New To JavaReplies: 9Last Post: 02-23-2011, 10:21 PM -
Newbie Question using the less than < operator
By mancsta in forum New To JavaReplies: 1Last Post: 12-01-2010, 11:27 PM -
Newbie question
By MrNiceGuy in forum New To JavaReplies: 8Last Post: 11-12-2010, 05:29 AM -
newbie question
By ronguilmet in forum New To JavaReplies: 2Last Post: 11-16-2009, 02:37 AM -
[SOLVED] Using dialog boxes and switch statements question
By hungdukie in forum New To JavaReplies: 2Last Post: 11-22-2008, 05:30 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks