Technology
 

Syntax

From Java Wiki

Welcome to the syntax page. Post Java syntax you know of here:

Print Line Syntax:
 System.out.println ("insert text here"); 
Execute Method Syntax:
 method(); 
Declare Public Method Syntax:
 public void insert method here() {

} 
Declare Public Class Syntax:
 public class insert class here { 

} 
Import Syntax:
 import insert import location here .*; 
Declare Private Method Syntax:
 private void insert method name here() {

	insert other method here(); 

} 
For Loop Syntax:
 for (int i=0; i<insert loop number here;i++) {

	insert method here();

} 
While Loop Syntax:
 while (insert condition method here()) {

	insert other method here();

} 
If Statement Syntax:
 if (insert condition method here()) {

	insert other method here();

} 
If Else Statement Syntax:
 if (insert condition method here()) {

	insert other method here();

} else {

        insert other method here();

} 
!!! Note: You can nest If statements !!!
Example:
 

     if (exampleCondition()) {
          
            if (exampleCondition2) {
			
                 exampleMethod ();

	    }

     } else {

            otherMethod();

     }