This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

my first Java nightmare  RSS feed

 
Jesse Crockett
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying another route. Should this work?

 
Garrett Rowe
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That looks fine to me. (By fine I mean it looks like it should work). Does it work like you expected it to?

IMO going through those "Java nightmares" just makes you stronger (to rewrite a tired cliche'). The next time, you will understand the pitfalls involved with this lesson. Especially with things like variable scope and shadowing primitive variables and such.

Garrett
[ February 10, 2006: Message edited by: Garrett Rowe ]
 
Jesse Crockett
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It still isnt working. I'm getting some weird ')' and '}' expected, for which I can't figure out where they should go. So I'm moving on to the next exercise, then maybe come back to this fresh (hopefully).
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This declaration:

static void printEmployeeInfo(StringBuffer employeeName, Double hourlyRate, Double hoursWorked, Double taxRate, Double pay[0], Double pay[1]) { ...

is causing the errors. The fact that you're passing array elements as arguments to this routine is irrelevant; when you declare the routine, you declare the arguments as plain old Doubles. The "Double pay[0]" syntax is what's wrong; you just want "Double pay0, Double pay1" or something like that (I don't know what those two elements represent or I'd give the parameters better names.)
 
Henry Wong
author
Sheriff
Posts: 23283
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jesse Crockett:
It still isnt working. I'm getting some weird ')' and '}' expected, for which I can't figure out where they should go. So I'm moving on to the next exercise, then maybe come back to this fresh (hopefully).


First of all, don't worry about the tons of errors messages from the compiler. Deal with it one at at time. Fix one, then compile again. With experience later, you'll learn to do more than one.

Second, the most important items with the error message is the file and line number. Get a good editor, open the file specified, go to the line specified, and start from there. Errors having to do with braces are generally cause eariler -- so you may have to back up a bit. Having an editor that will help you match braces, would be a good idea too. Again, this will improve with experience.

Henry
 
Megs Maquito
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmmmm, shouldn't an array be initialized as:

int [] myArray = {1,2,4}//use{} instead of ()
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!