This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes also need help this code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "also need help this code" Watch "also need help this code" New topic
Author

also need help this code

bob michelle
Greenhorn

Joined: Dec 15, 2011
Posts: 2


main class
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4344
    
    8

Hi Bob. Welcome to the Ranch! You need to actually ask a question if you want us to help you effectively, though. What specifically do you need help with?
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11167
    
  16

at the very least, it looks like your inputAnimals method isn't closed...I think someone got a little trigger happy when commenting out stuff. The brace on line 35 needs to be uncommented (I think).


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38045
    
  22
I think you are dealing with too much code all at once. You should write, maybe, five lines only before compiling and running whatever code you have. That way you find errors much more quickly.
You should also, I think, write write some of your } backwards. As you will see from the link, “backwards” means you write lines in a different order from what you usually do.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11167
    
  16

Campbell Ritchie wrote:You should write, maybe, five lines only before compiling and running whatever code you have.

FIVE? IMHO, that is still way too many. I never go more than 2-3.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38045
    
  22
That’s six lines, and still does nothing much.

You have four lines each containing only { or }, so you ain’t going to get very far with three lines

But Fred and I agree that you must write little bits of code and make sure they work before going on to the next bit.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11167
    
  16

hmmm....maybe I don't really count "lines" of code. i would consider this to be one:

since technically, it can be written on one line:

and yes, so could your original six lines:

but that's just silly.

I guess I don't count braces as 'lines of code' since they can be written in so many different ways.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38045
    
  22
I think your line arithmetic and mine will result in our both writing the same amount of code at a time
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: also need help this code
 
Similar Threads
Suppressing proceeding statements after if statement fails
Java Methods code. Someone help please
Switch sends my class object to the trash
Passing values between classes in two separate files
help converting my code into classes and arrays