Results 1 to 4 of 4
Thread: Loop inside a switch
- 02-26-2010, 12:29 AM #1
Member
- Join Date
- Dec 2009
- Posts
- 33
- Rep Power
- 0
-
I'm not sure I get exactly what you're trying to do here. If you don't get a decent answer by others, you may want to expand on your explanation a bit and even post a code attempt at solving it.
Much luck!
- 02-26-2010, 12:40 AM #3
Senior Member
- Join Date
- Feb 2010
- Location
- Ljubljana, Slovenia
- Posts
- 470
- Rep Power
- 4
Why would you even need a switch?
Java Code:public static void printchar(char c) { for(int i = 0; i < 30; i++) System.out.println(c); }
- 02-26-2010, 03:25 AM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Yes, why are embedded a loop in switch. It's not a good design at all, if someone else read your code will confuse, and difficult to understand.
As m00nchile suggest in the above post, do that looping stuff in a different method, and call the appropriate method in case statement. There is no limitation, you can use many number of methods within your classes.
Similar Threads
-
Problem printing inside FOR loop
By cassysumandak in forum New To JavaReplies: 1Last Post: 10-04-2009, 05:02 PM -
Inside a Timer thread loop,how to refresh a JTable in swing
By neha_negi in forum Threads and SynchronizationReplies: 3Last Post: 09-04-2009, 01:45 AM -
println doesn't print from inside for loop, et.al.
By rdtindsm in forum New To JavaReplies: 5Last Post: 03-27-2009, 01:19 PM -
switch
By dj kourampies in forum New To JavaReplies: 2Last Post: 01-30-2009, 08:46 AM -
Switch help please!!!!
By soc86 in forum New To JavaReplies: 6Last Post: 11-23-2008, 07:25 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks