Back Button
Back to Chapter
No items found.
Table of Contents

The best way to learn a new language is to write a few simple example programs and execute them.

public class HelloWorld { /* This will print 'Hello World' as the output */ public static void main(String args[]) { System.out.println("Hello World"); // prints Hello World } }

  • String args[]- It is the main function that has String arguments.
  • System.out.println() - It is used to print the content in a new line. Let's learn more about it in upcoming chapters.
  • Case Sensitivity − Java is case sensitive, which means the identifier Hello and hello would have different meanings in Java.
  • Class Names − For all class names the first letter should be in Upper Case.
  • Example: class HelloWorld
  • Method Names − All method names should start with a Lower Case letter.
  • Example: public void main()
  • Program File Name − Name of the program file should exactly match the class name
class HelloWorld // ✔️ valid ( starts with uppercase ) class helloworld // ❌ invalid ( starts with lowercase )