Trying to run a program that swaps names. The task is simple: input > Alice Bob Alex, output > Alex Bob Alice P.s. Maybe the problem is stupid, but I just recently started programming, so I don't know what to do
I try to run the code in Eclipse - gives an index error. I start in the console - gives an error of the main name. Tried to pass through the internal debugger in Eclipse - writes that I am using obsolete methods. In the end, nothing is clear./
public class Noob {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.print(args[2]);
System.out.print(" " + args[1]);
System.out.println(" " + args[0]);
}
}
- Error message from Eclipse:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 2 out of bounds for length 0 at noob/noob.Noob.main(Noob.java:7)
- Console (the file name is Noob.java)
- First I compiled src file (> javac Noob.java)
- Then I ran it (> java Noob)
Error: Could not find or load main class Noob Caused by: java.lang.NoClassDefFoundError: noob/Noob (wrong name: Noob)