New Posts  All Forums:Forum Nav:

Beginner Java question.... - Page 3

post #21 of 24
Quote:
Originally Posted by flamingoyster View Post
If you have multiple conditions under which you want to break I can see why you'd want to do it that way. However, that is not the case here...if there's a way to accomplish that loop that's just as simple without using an infinite loop, then the infinite loop should be discouraged.
In this case you don't know how much data the user wants to average. An unbounded/infite loop is the most logical way to go.

If you are arguing that you should not use while(1) or a equivalent in this case, I agree, which is why I recommended using while(input.compareTo("done") != 0)
Edited by Xazen - 3/18/11 at 7:18pm
Scream Machine
(9 items)
 
  
CPUMotherboardGraphicsRAM
i7-4770K Gigabyte Z87X-UD3H EVGA GTX 780 16GB DDR3 
Hard DriveCoolingOSMonitor
256GB Samsung 840 Pro Kraken X60 Windows 7 Shimian 2560x1440 
Case
Phantom 630 
  hide details  
Reply
Scream Machine
(9 items)
 
  
CPUMotherboardGraphicsRAM
i7-4770K Gigabyte Z87X-UD3H EVGA GTX 780 16GB DDR3 
Hard DriveCoolingOSMonitor
256GB Samsung 840 Pro Kraken X60 Windows 7 Shimian 2560x1440 
Case
Phantom 630 
  hide details  
Reply
post #22 of 24
Quote:
Originally Posted by Xazen View Post
An unbounded/infite loop is the most logical way to go.
Since their is no timing or use of a separate thread, if there was an error with the .next() method returning a bad String or 'done' doesn't exist then the process would hang, eventually crash.

I mean, it's a good way to go if you have the loop set up correctly, but from the sample posted that isn't the case.
Main PC
(13 items)
 
  
CPUMotherboardGraphicsRAM
955 Phenom II X4 BE Asus am3 240 GT 4GB 
Hard DriveOptical DriveOSMonitor
500GB Sata Sony BR Reader + DvD R/W Windows 7 Bush + LG (19 + 20) 
KeyboardPowerCaseMouse
Bush 700w Avenge Power R.A.T 3 
Mouse Pad
kensington 
  hide details  
Reply
Main PC
(13 items)
 
  
CPUMotherboardGraphicsRAM
955 Phenom II X4 BE Asus am3 240 GT 4GB 
Hard DriveOptical DriveOSMonitor
500GB Sata Sony BR Reader + DvD R/W Windows 7 Bush + LG (19 + 20) 
KeyboardPowerCaseMouse
Bush 700w Avenge Power R.A.T 3 
Mouse Pad
kensington 
  hide details  
Reply
post #23 of 24
Thread Starter 
I added a new question to the Op
post #24 of 24
Thread Starter 
Nevermind, everyone. I finally got it fixed!
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Application Programming