Support us .Net Basics C# SQL ASP.NET ADO.NET MVC Slides C# Programs Subscribe Buy DVD

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

If you like this website, please share with your friends on facebook and Google+ and recommend us on google using the g+1 button on the top right hand corner.