NoSuchMethodError Exception

I keep getting a NoSuchMethodError Exception for the code shown below.

import java.util.*;

import java.lang.*;

import java.io.*;

public class test{

private String readit()

{

// Set the default return value - a blank string

String input = "";

// Create an input stream reader to read from Standard Input (Keyboard)

InputStreamReader isr = new InputStreamReader( System.in );

// Create a buffered reader around the stream reader

// this allows you to read line at a time instead of char by char

BufferedReader br = new BufferedReader( isr );

try

{

input = br.readLine();

}

catch (IOException ex)

{

System.out.println( "Error reading keyboard input." );

}

return input;

}

public void main(String args[]){

try{

String out = "Java is the best language in the world";

readit();

int array[] = new int[5];

for(int i = 0; i < 5; i++){

array = i;

System.out.println(array[i + 1]);

}

array[1] = -9;

}

catch( ArrayIndexOutOfBoundsException e){

System.out.println("Error ");

}

}

}

I don't know why this is but is something to do with calling the readit() method in main, Can anyone tell me how I could get around this or why this is happenning.

[1390 byte] By [zimbaa] at [2007-10-2 12:54:46]
# 1
main method should bepublic static void main(String args[]) but you have (missing 'static')public void main(String args[])
sundararajan.aa at 2007-7-13 10:09:40 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 2
I know I should have static in be when i put this in it won't compile and gives the following error:non-static method readit() cannot be referenced from a static contextreadit();^
zimbaa at 2007-7-13 10:09:40 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 3

To get around javac compilation error, you can't make main method as non-static! You either have to

* create an object of your class and then call readit() on it

* or make readit() method as static as well.

If you are new to Java, you may want to refer to http://java.sun.com/docs/books/tutorial/getStarted/index.html

sundararajan.aa at 2007-7-13 10:09:40 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 4
I want to use readit(); to read a specific webpage.Can i?Or how can i read a webpage?For example : readit( http://www.referate10.com/referate/Sonstige/3/Sonstige5.php );readit_link( http://www.referate10.com/referate/Physik/6/Physik3.php );
heidy23a at 2007-7-13 10:09:40 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...