Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using using an enhanced for loop

 
Kody Wright
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 618
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In getHourlyWage(), what is the purpose of the while (true) ?
 
Kody Wright
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 50196
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 50196
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why is hourlyWage static? Do you mean you want all your employees on the same hourly rate?
 
Campbell Ritchie
Sheriff
Pie
Posts: 50196
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Having seen your switch block, I am sure you were mistaken to make hourlyWage and choice static.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic