Let us understand the how java
public class Example {
public static void main(String[] args) {
System.out.println("Hi, Have a nice Day");
}
}
class : class keyword is used to declare classes in
Java
public : It is an access specifier. Public means this
function is visible to all.
static : static is again a keyword used to make a function
static. To execute a static function you do not have to create an Object
of the class. The main() method here is called by JVM,
without creating any object for class.
void : It is the return type, meaning this function will
not return anything.
main : main() method is the most important method in a Java
program. This is the method which is executed, hence all the logic must
be inside the main() method. If a java class is not having a main()
method, it causes compilation error.
String[] args : This represents an array whose type is
String and name is args. We will discuss more about array in Java Array
section.
System.out.println : This is used to print anything on the
console like printf in C language.
No comments:
Post a Comment
If any suggestions or issue, please provide