It's not a secret anymore!*
The moose likes Java in General and the fly likes Using using an enhanced for loop Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Using using an enhanced for loop" Watch "Using using an enhanced for loop" New topic
Author

Using using an enhanced for loop

Kody Wright
Ranch Hand

Joined: Mar 06, 2011
Posts: 32
Hello!

I am writing a program for my Java class and am having some difficulties with an enhanced for loop not running at the end of my driver class. Although no errors show up in the eclipse programming tablet area, if I run the program (EmployeeApp) it will not show the showMessageDialog that it is supposed to and becomes SUPER slow, followed by a list of errors.

I'll copy the programs below. I can't figure out what exactly is wrong, it could very well be something simple. Any help or ideas would be greatly appreciated...thanks for your time. : )










Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4344
    
    8

Hi Kody. Welcome to the Ranch!

The code you've posted won't compile: line 22 of EmployeeApp has an error. Could you correct that first? Thanks.
Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
In getHourlyWage(), what is the purpose of the while (true) ?
Kody Wright
Ranch Hand

Joined: Mar 06, 2011
Posts: 32
Fixed the error in line 22 of EmployeeApp, thanks for pointing that out.

As for the while(true)...I'm not sure why I put that in lol. Regardless, it is fixed.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38107
    
  22
You have a no-arguments constructor which sets the name and id as null. That is dangerous; you don't want null references floating round in your code. Delete that constructor, and also the = null bits of the field declarations. Obviously any code which calls that no-arguments constructor will no longer compile, and will have to be altered.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38107
    
  22
Why is hourlyWage static? Do you mean you want all your employees on the same hourly rate?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38107
    
  22
Having seen your switch block, I am sure you were mistaken to make hourlyWage and choice static.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using using an enhanced for loop
 
Similar Threads
overriding hashcode and equals method internal work flow
array being overwritten
Code problems
Needs help in editing
what is the error in this program