*
The moose likes Beginning Java and the fly likes Compiling error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Compiling error" Watch "Compiling error" New topic
Author

Compiling error

julia lamenza
Greenhorn

Joined: Sep 21, 2011
Posts: 2
I have this code

and when i try to copile this they say that i have an error in tthe int part
please help
Unnar Björnsson
Ranch Hand

Joined: Apr 30, 2005
Posts: 164
change .lenght to .length
mike ryan
Ranch Hand

Joined: Aug 08, 2010
Posts: 210



you should spell length properly , also you should use code tags to post your code, it is easier to read. And start your own thread to get help rather than jumping in to an older post to get more attention to your problem rather than the problems from the older post that have already been taken care of.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11175
    
  16

mike ryan wrote:you should use code tags to post your code, it is easier to read. And start your own thread to get help rather than jumping in to an older post

Agreed. i took care of both.

Julia - next time, please use code tags. They make your code much easier to read, assuming your code is formatted with proper indentation. They work the same way as the 'italic' or 'color=red' tags work. Simply highlight it and click the 'code' button.

Personally, i wouldn't have these three lines at all:



but would instead do this:


My reasoning is that

1) it is possible that in between getting the length and using it, your array could change. Granted, not with the code you have here, but it is possible.
2) why store the same value twice? You can get the length(s) whenever you need it, so why get it and store it again? It's just redundant data.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
julia lamenza
Greenhorn

Joined: Sep 21, 2011
Posts: 2
thank you guys
 
Consider Paul's rocket mass heater.
 
subject: Compiling error
 
Similar Threads
phraseomatic code
Once Over
unclosed string literal error
The correct version of the Phrase-O-Matic (ref:Head First Java)
PhraseOMatic syntax problem in Head First Java