Java 9
Java 9
============
Our program contains main method or not.Either it is properly declared or not.It is
not a responsibility of a compiler to check.It is a liability of a JVM to look for
main method.
If we perform any changes in above signature then we will get runtime error called
main method not found.
public
-----
JVM wants to call this method from anywhere.
static
------
JVM wants to call this method without using object reference.
void
----
Main method does not return anything to JVM.
main
----
It is an identifier given to main method.
String[] args
----------
It is a command line argument.
ex:
javac Test.java
ex:
---
class Test
{
public static void main(String[] args)
{
System.out.println(args[0]);
System.out.println(args[1]);
System.out.println(args[2]);
System.out.println(args[3]);
}
}
class Test
{
public static void main(String[] args)
{
System.out.println("Enter the Name :");
String name=args[0];
System.out.println("Welcome :"+name);
}
}
javac Test.java
System.out.println()
====================
It is a output statement in java.
If we want to display any userdefined statements and data then we need to use
output statement.
syntax:
-----
static variable
|
System.out.println();
| |
predefined predefined method
final
class
Diagram: java9.1
ex:
---
class Test
{
public static void main(String[] args)
{
System.out.println("stmt1");
System.out.print("stmt2");
System.out.printf("stmt3");
}
}
2)
int i=10;
System.out.println(i);
System.out.println("The value is ="+i);
3)
int i=10,j=20;
System.out.println(i+" "+j);
System.out.println(i+" and "+j);
4)
int i=1,j=2,k=3;
System.out.println(i+" "+j+" "+k);
EditPlus Editor
==============
Download link : https://www.editplus.com/download.html
We will declare class name and interface name along with package name.
ex:
java.lang.System
java.lang.String
java.lang.Object
ex:
---
class Test
{
public static void main(String[] args)
{
java.util.Date d=new java.util.Date();
System.out.println(d);
}
}