This week's book giveaway is in the General Computing forum.
We're giving away four copies of Learning Regular Expressions and have Ben Forta on-line!
See this thread for details.
Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Using using an enhanced for loop  RSS feed

 
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. : )










 
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.
 
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.
 
Marshal
Posts: 60169
188
  • 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
Marshal
Posts: 60169
188
  • 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
Marshal
Posts: 60169
188
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!