Support us .Net Basics C# SQL ASP.NET Aarvi MVC Slides C# Programs Subscribe Download

Java hello world explained

Suggested Videos
Part 1 - Java introduction for beginners
Part 2 - Java basics for beginners

Our "Hello World!" program consists of three primary components:
  • Source Code
  • Comments
  • Class definition
  • Main method


Comments are ignored by the compiler but are useful to other programmers. 

/* MultiLine Comments */
/** Java Documentation Comments */
// Single Line Comments

Note : The compiler ignores everything from // to the end of the line.



Understanding Hello World

public : is an access modifier that means it will be accessed by every class out there
void : is a return type i.e it does not return any value
main() : is a method or a function name.

Program

/*
This is a multi
line comment
*/

// Single Line Comment

public class Program
{
    public static void main(String[] args)
    {
        System.out.println("Hello World");
    }
}

Compilation
$ javac Program.java

Execution
$ java Program

java tutorial for beginners

No comments:

Post a Comment

It would be great if you can help share these free resources