Reputation: 103
Why won't my program find my main class? I don't think you need the rest of the parse() function to understand what is wrong... let me know
package help;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class help {
ArrayList<Character> StringList = new ArrayList<Character>();
static char[] data;
String val;
public void main(String[] args){
InputStreamReader ISR = new InputStreamReader (System.in);
BufferedReader BR = new BufferedReader(ISR);
try{
int sCurrentChar;
while ((sCurrentChar = BR.read()) != -1) {
parse((char) sCurrentChar);
}
} catch(IOException e){
e.printStackTrace();
}
}
public void parse(char x){
boolean done =false;
int state =0;
Upvotes: 0
Views: 195
Reputation: 4631
You need to have a
public static void main(String [] args){
rather than
public void main(String [] args){
You don't have it as static
Upvotes: 0
Reputation: 525
Yes because signature of the main method requires static. public static void main(String args[])
Only at this point the JVM will recognize the main method as the entry point of the program and will execute.
You will need to have parse method to be static if you want in the same class.
Or else you can use a separate class for parsing..
Upvotes: 0
Reputation: 4252
The correct way to declare main method is :
public static void main(String args[]){
........
}
Upvotes: 0
Reputation: 34146
The main()
method needs to be static
:
public static void main(String[] args) {
...
}
For further information, read Why is the Java main method static?.
Also, I would recommend you to follow Java naming conventions. Member names of the form someMember
, and class names of the form SomeClass
.
Upvotes: 6