Execution error: NoSuchMethodError: Main
Hello all,
I have an assignment due (today, of course) and the instructor outlines in the assignment sheet that we need to declare main using:
Code:
public static int main (String args[])
The program compiles correctly, naturally, but when executing it says this:
Code:
Exception in thread "main" java.lang.NoSuchMethodError: main
Normally this error is pretty simple to diagnose, since usually in that case main is missing entirely. Anyways, I realize there are some logical errors in this programs, and some overly complex ways of doing things... Gotta do it the way the instructor says.
Can anyone shed some light on this problem? Thanks a lot guys
Heres the complete code:
Code:
import java.util.Scanner;
public class kharnden_Decimal
{
static int con;
public static int main( String args[] )
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter a positive number up to 8 digits (Fmt: 00000000)");
con = sc.nextInt();
System.out.print(con + ":" + convert(con));
return con;
}
public static int convert ( int octalNumber)
{
int d1, d2, d3, d4, d5, d6, d7, d8;
String in = Integer.toString(con);
d1 = in.charAt(0) - 48;
d2 = in.charAt(1) - 48;
d3 = in.charAt(2) - 48;
d4 = in.charAt(3) - 48;
d5 = in.charAt(4) - 48;
d6 = in.charAt(5) - 48;
d7 = in.charAt(6) - 48;
d8 = in.charAt(7) - 48;
con = (d1 * 8^7) + (d2 * 8^6) + (d3 * 8^5) + (d4 * 8^4) + (d5 * 8^3) + (d6 * 8^2) + (d7 * 8^1) + (d8 * 8^0);
return con;
}
}