Click to See Complete Forum and Search --> : First Java Program Errors


Arcane_Disciple
03-02-2003, 01:49 AM
public class Welcome
{
public static void main(String[] args)
{
String[] greeting = new String[2];
greeting[0] = "Hello";
greeting[1] = "This is my first Java program";

for (int i = 0; i < greeting.length; i++)
System.out.println(greeting[i]);
}
}

Here is my error


testing/testing.java [1:1] class Welcome is public, should be declared in a file named Welcome.java
public class Welcome
^
1 error


I got this example from a website and copied word to word. What is wrong with it?

X_console
03-02-2003, 03:15 AM
Did you save it in a file called Welcome.java (case sensitive)?

Arcane_Disciple
03-02-2003, 03:55 AM
Actually I named it TestFile. Once I changed it, it worked fine. Thanks for the help.