Ask coding questions

← Back to all posts
Question
ajefferson47

My first program gives an "Error" when I run it. Can anyone share what might be the problem?

I wrote my program in Notepad as the following:
Public Class HelloWorld {
Public static void main(String[] args) {
System.out.println("HelloWorld");
}
}

Then I saved it in a folder at the root of my C: drive and named the folder "Revature Programs".

I then opened my "Command Prompt" and changed the directory structure to where the file was saved as follows:

C:\Revature Programs>javac HelloWorld.java

Here's what I get back as a result:

HelloWorld.java:1: error: class, interface, enum, or record expected
Public class HelloWorld {
^
1 error

Voters
ajefferson47