Sunday, 4 December 2016

Syntax of valid .java file.

Syntax of valid .java file

package p1; --------->>     package Declaration
import my package.*; --------->>     package importing
@TestAnnotation --------->>     use the annotation

class <Class_name>
{
Variable declaration;
Method declaration;
}


Components of the our 1st program Demo.java

class Demo
class    ---------->>          keyword
Test     ---------->>          identifier (user defined name)


public static void main(String []args)
public    --------->>        Access specifier                        ----------->>           keyword
static      --------->>        Access modifier                       ----------->>           keyword
void       --------->>        Return type of main method     ----------->>           keyword
main       --------->>        Method name
String    ---------->>       Library class of java
[]args     ---------->>       Identifier(name of Array)


System.out.println();
System     --------->>        Library class
out           --------->>        Object of PrintStream class
println      --------->>        Method of PrintStream

Println: - after println the statement println place the cursor on the new line.
System.out.print();

Print: - It wills the cursor in same line after printing the same line.



No comments:

Post a Comment