
Common Mistakes Java Beginners Makes
✔️ Correct Code : public class Home { public static void main ( String [] args ){ System . out . println ( "hello world" ); } } ❌ 1. Class name and file name don’t match. public class home{} my actual file name is Home.java, above the code class name is home. File name must be Home.java Otherwise you will get a compile error OUTPUT ERROR: ❌ 2. Wrong main method syntax public static void main (String{} args){ } ✔️ What is String[] args? It is an array of strings It stores command line arguments when the program runs OUTPUT ERROR: ❌ 3. Missing semicolon (;) System.out.println("hello world") 👉 You must add ; ❌ Otherwise error OUTPUT ERROR: ❌ 4. Wrong capital letters system.out.println("Hello"); 👉 Java is case-sensitive ✔️ Correct is System OUTPUT ERROR: ❌ 5. Missing curly braces { } public class Home { public static void main ( String [] args ) { System . out . println ( "Hi" ); 👉 You forgot closing } ❌ This will cause an error OUTPUT ERROR: ❌ 6. Missing quotes System.out.println("Hello W
Continue reading on Dev.to
Opens in a new tab


