• Post Reply Bookmark Topic Watch Topic
  • New Topic

Failed to compile, Main Method Not found  RSS feed

 
Ricardo Santiago
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

stingininnerclass.jpeg
[Thumbnail for stingininnerclass.jpeg]
 
Ricardo Santiago
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am learning using the Head First Java Book and this is one of the actifvites, the code is taken straight from the book but will not compile on my system.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37496
547
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch! I added code tags to make the code easier to read.

You are missing a }, There needs to be another one right after:



This extra } closes the first class. That's what is confusing Java - it thinks the second class is part of the first. And it isn't intended to be.
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It becomes a lot more obvious what the problem is (which Jeanne has decribed) if you indent the code consistently - I've just updated it to do that. It's a good habit to get into.
 
Pablo Jose Alvarez
Greenhorn
Posts: 17
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You also misspelled 'args' in main(). Hope that helps
 
Paweł Baczyński
Bartender
Posts: 2083
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pablo Jose Alvarez wrote:You also misspelled 'args' in main(). Hope that helps

Actually this is irrelevant. By the convention the parameter of main method is called args but the truth is you can use any legal identifier.
 
Pablo Jose Alvarez
Greenhorn
Posts: 17
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah...good to know! Thanks!!
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!