Hello everyone, I just recently started studying Java on my own using the book Head First Java and everything was going rather smoothly until the sixth chapter with the battleship-ish game, where I'm getting an error I have no idea how to fix since from what I know so far, the code's supposed to work.
I did check the web for the error and found some answers, however, most of them did not apply here (at least I don't think they do) since I'm declaring a method and the ones that were somewhat similar didn't work at all (for example, there was one that mentioned that the code given in the HFJ website worked once a line was fixed, but here it didn't work either.
For those familiar with the book, both the DotCom and GameHelper classes are on the same folder as the DotComBust and I typed them myself (they both compiled just fine).
And not sure if it makes any difference (shouldn't), but I'm doing all this on a mac, using the text edit to type all the code (but I have converted it to plain text instead of the default rich text).
Well, without further ado, here's the code:
And here's the error list:
The setName method refers to the DotCom class that is in another file at the same folder and is coded to take an nString.
Pedro Fonseca wrote:And thanks for the tip, it looks like it's indeed time to get an IDE.
Most of the old timers here would strongly recommend you NOT use an IDE. at least, not yet. If you are just learning java, you need to learn it. Using an IDE causes you to learn the IDE, and you miss some of the fundamentals.
I would also say you should NEVER have gotten this far on this code. NEVER NEVER NEVER write more than 2-3 lines before you compile. If the first time you attempt to compile you have 70 lines of code, you are in for a world of hurt.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors