• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Page 30 of K&B

 
Gaetan Ve
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys, i already looked through the forum but couldnt find the answer on page 30 im trying to run this code



but i get the error selection does not have a main type. How do i fix this? Im using eclipse by the way.

Thanks in advance
 
Steve Rooney
Greenhorn
Posts: 1
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That code want run because you don't have a main method that sits inside a public java class.

The run an instance of the Moo class you can put the following underneath your code:
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gaetan,

First of all, a warm welcome to CodeRanch!

Gaetan Ve wrote:but i get the error selection does not have a main type. How do i fix this? Im using eclipse by the way.

Just add a main method in one of the classes you already haveOr you could define a method in another class as well

Hope it helps!
Kind regards,
Roel

PS. When posting code, you should use code-tags. They improve the readibility of your post (and so you are more likely to get an answer). I added them for you in your post.
 
Gaetan Ve
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another question, when eclipse ask me to run it. Should i run as a Java Applet of Java Application, i've never had eclispe ask me this with any other codes
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gaetan Ve wrote:when eclipse ask me to run it. Should i run as a Java Applet of Java Application, i've never had eclispe ask me this with any other codes

Java application. An applet runs in the browser.

Some advice: you should not use Eclipse or any other IDE. When preparing for a certification exam (certainly if you are new to Java), you should use nothing but your favourite text editor to write (little) programs, javac to compile your code and java to run your compiled classes.
 
Gaetan Ve
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks I didnt know this, all the tutorials online ive seen use either netbeans or eclipse so thats why i installed it but will keep it in mind.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic