dswimboy
04-09-2004, 06:47 AM
My code compiles correctly everytime, but if i change anything, i must also change the name of class Lab168 to get the program to run. i get the runtime error of "Exception in thread "main" java.lang.NoSuchMethodError: main". why do i have to change the class name each time?
class Lab168 {
public static void main (String args[]) throws IOException {
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter a string: ");
Palindrome p = new Palindrome(input.readLine());
p.displayData();
}
}
class Palindrome {
private String s;
private String p;
public Palindrome (String x) {
s = x;
}
public void displayData() {
System.out.println("string: " + s);
}
}
class Lab168 {
public static void main (String args[]) throws IOException {
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter a string: ");
Palindrome p = new Palindrome(input.readLine());
p.displayData();
}
}
class Palindrome {
private String s;
private String p;
public Palindrome (String x) {
s = x;
}
public void displayData() {
System.out.println("string: " + s);
}
}