• Post Reply Bookmark Topic Watch Topic
  • New Topic

public static main void issue  RSS feed

 
Jonathan Mckulsky
Greenhorn
Posts: 13
Chrome Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having an issue with line 15.I can't figure out how to fix it. Any tips?

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66306
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look very very carefully at the line.
 
Jonathan Mckulsky
Greenhorn
Posts: 13
Chrome Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I fixed the capitalization of "void". Now I'm getting "Illegal satic declaration in inner class Salesperson1.Salesperson modifier 'static' is only allowed in constant variable declararions." on the same line.
 
Paul Clapham
Sheriff
Posts: 22832
43
Eclipse IDE Firefox Browser MySQL Database
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've got a class named Salesperson inside the class named Salesperson1. Since you're in Beginning Java you probably didn't mean to do that. Especially since your public-static-vold-main method is inside the inner class (which causes the error message). I'd suggest getting rid of the inner class (Salesperson) declaration -- but keep the contents!
 
Jonathan Mckulsky
Greenhorn
Posts: 13
Chrome Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any way i can shorten my code to make it only have "Enter total sales" only once? And also make it look easier on the eyes because i feel it is very scattered?
 
Junilu Lacar
Sheriff
Posts: 11493
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have everything jammed into your main() method.  That is what is making your program looks very scattered and confusing.

A readable program is broken down into smaller chunks, each chunk handling one small part of what the program does. This is what's called functional decomposition. If you look under the hood of a typical car, it can look like a confusing jumble of parts but each part actually has its own little function and it's separated from the other parts that provide different functions. That's why when you go in to get an oil change, the mechanic knows to go to the underside of the engine and look for the drain plug. He won't have to fool around with the battery or other unrelated part. A program should be like that. If you need the program to do the same thing multiple times, then you need to separate the code that does that repetitive task to be in its own method. See the Java Tutorial to learn how to define methods.

You might also want to check out our wiki about how MainIsAPain (←that's a link)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!