Hello World - Java
A "Hello, World" program is a very simple program in the most programming languages. The "Hello, World" program shows the basic syntax of the programming language.
Text Editors
Text Editor is a computer program and available in every Operating System for writing plain text files. A plain text file can be a source code of a program.
- Windows Text editors- Notepad, Notepad++.
- Linux Text editors - Vi/Vim Editor, Gedit, Nano Editor.
- Mac Text editors - Brackets, TextWrangler, TextMate.
First program
Class - A class is the basic building block of the an object oriented programming language that contains methods, properties and inner blocks. A single source file can have multiple classes with unique class identifiers.
HelloWorld - HelloWorld is a unique class identifier. A source file can not have duplicate class names.
{ } curly brackets - It defines block of the code for classes, methods, blocks, decision statements and iterative statements.
public - Public is an access identifier that gives the public access to caller of main method within a class, within a package, outside of the package by subclass and outside of the package.
static - static is a reserved keyword that is reserved for special purpose. static is used for calling a method by method name without creating an instance of the class.
void - void is a reserved keyword which is used in the signature of methods for telling that method returns nothing.
main - main is the name of method.
( ) parentheses - Parentheses are used to defined method signature with parameters.
System - System is a class; out - out is a static member of System class and have instance of PrintStream class; println - println is a method of PrintStream class.
; semicolon or terminator symbol - It is used to stop a statement in programming languages.
Steps to Write a Java program
- Open text editor.
- Write above program.
- Save file to Desktop with "HelloWorld.java" file name.
Steps to Compile a Java program
- Open command prompt.
- Go to Desktop where you have saved your file.
- write command to compile Java source file "javac HelloWorld.java".
Steps to Run a Java program
- write a command to run program "java HelloWorld"