• Post Reply Bookmark Topic Watch Topic
  • New Topic

Main selection  RSS feed

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys i'm still having trouble with wrapping my head around the
and where exactly im supposed to put it in my code.

I have two classes im trying to compile


and


So where do i put it here? Or some general guidelines as to where to put it.
 
Marshal
Posts: 56600
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have several problems there. Start by removing the package names. If you are wondering about how to compile things you should not use package names because they will simply confuse you. Also remove the import which will not be necessary.
You can compile those classes without package names simply by using the javac command.
The main method (which has an error in: there is a stray ] symbol) is for starting your application. Read about it in our FAQ.
 
Gaetan Ve
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im just copying the code from K&B studyguide, so their codes are incorrect? Even more confused now lol but will try it your way.
 
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can put the main() method in whatever class you want. It's just a method, like any other method.

Ofcourse, when you want to run your program, you'll have to specify the name of the class that contains the main() method to the java command.
 
Campbell Ritchie
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe the K&B guide is intended for people who have enough experience to sit the certification exam, so they will be used to package names. You are obviously a green beginner, so package names will simply confuse you.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!