Class FirstJavaProgram
{
public static void main (String [] args)
{
System.out.println("Hello World!");
} // main
} // class
In Java Program EveryThing is a CLASS.
1- First we write class and class_name
2- main() method
3- method/function to display something to the screen
--> These three steps are needed to follow for understanding & execution of the program.
******************************************************
# Syntax Of CLASS
Accessibility_Modifier are -
- public
- private
- protected
Modifiers are -
- final
- static
- abstract
- many more (Will see all of them later)
class - class is a keyword. It should be written as it is. [all the keyword are written in small letters in java ]
Class_Name - Here "FirstJavaProgram" is a name of the class.
******************************************************
Now, Main() Method
*This Is Very Important (It may chance to asks question on this in an interview room)
we will see this later when you are in a position to understand these concepts.
As of now I just introduce these words to you.
[Note - by heart this line (without this line you cannot run any program in java)]
public - is an access modifier.
static - is a keyword.
void - it is a DATA TYPE.
main() -
- it is the name of main() a method.
- JVM is always looking for the main() method.
- it is the parametrized method, it takes one argument of string type of array.
- You can't change its name, if you want to do so - for that you have to customize your JVM and it is almost impossible.
String [] args - String is a class in java and args is the name of string type array.
As of now, it is enough but still, you want to know more about " public static void main(Strings [] args) "
Then I am going to give you video link - that will help you to understand this line clearly.
[ Video -public static void main(Strings [] args) == 1st part ]
[ Video -public static void main(Strings [] args) == 2nd part ]
[ Video -public static void main(Strings [] args) == 3rd part ]
******************************************************
Now, Output Stream
System.out.println(); - helps to display something on the screen.
System - is a class. (I told you before every thing in java is a class)
out - is a static variable.
println() - is a method of System Class.
As of now, it is enough but still you want to know more about System.out.println();
Then i am going to give you video link - that will help you to understand this line clearly.
[ Video - Explanation about System.out.println(); ]
******************************************************
Now, Comments
- Comments are something that is unreadable in java.
- it is used to increase the readability of the program.
- Java Compile ignores it.
- Two Types of Comment in Java
- Single Line Comment
- Multiple Line Comment
- Documentation Comment
// double forward slash used for single line comment
/*
* this is used
* for multi-line comment,
* what every written inside these ( /* _comment_ */ ) is never
* executed at all.
*/
/**
* it appears in blue color
* this comment is for other developers
* These comments have some "@" words
* used for -- last modification date, developed by, modified by etc
*/
No comments:
Post a Comment