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

publicclassProgram
{
publicstaticvoid 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

[フレーム]

Subscribe to: Post Comments (Atom)

AltStyle によって変換されたページ (->オリジナル) /