Java Short Explanation

 

Important Web Address for Java

                               Sun's main Java Web site                                                                Java documentation

                               www.java.sun.com                                                                        java.sun.com/javase/reference

                                Jakarta tomcat site

                                tomcat.apache.org

                                TextPad

                                www.textpad.com

 

 

 

Primitive Data types

Type Wrapper Class Parse Method
int Integer Integer.parseInt(String s)
double Double Double.parseDouble(String s)
short Short Short.parseShort(String s)
long Long Long.parseLong(String s)
byte Byte Byte.parseByte(String s)
float Float Float.parseFloat(String s)
char Character none
boolean Boolean Boolean.parseBoolean(String s)

 

Operators

Arithmetic  
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulus / Remainder
++ Increment
-- Decrement
-= Subtraction and Assignment
+= Addition and Assignment
/= Division and Assignment
%= Remainder and Assignment
*= Multiplication and Assignment

 

Relational  
== Equal
!= Not equal
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to

 

Logical  
! Not
& And
| or
&& Condition And
|| Condition Or

 

Math Class

num max(num x, num y) The maximum of x and y
num min(num x, num y) The minimum of x and y
num abs(num x) The absolute value of x
int num = math.random() Random number from 1 to 10

 

The NumberFormat class

NumberFormat getNumberInstance() Gets the instance of which format numbers
NumberFormat getCurrencyInstance() Gets the instance which formats currency
String format(x) Formats a specified number

 

Java Statements

Statements Examples
The break statement break;
The continue statement continue;
The for statement for( initial; condition; counter)
{

        statements;

}

 

The enhanced for statement for( type variable : array or collection of objects)
{

      statements;

}

 

The while statement while( condition )
{

    statements;

}

 

The do-while statement do
{

     statements;

}while( condition );

 

The if statement if( condition )
{

    statements;

}
else
{

     statements;

}

 

The else-if statement if ( condition )
{

     statements;

}

else if( condition )
{

     statements;

}

else
{

    statements;

}

 

The switch statement switch ( condition )
{

    case constant:

          statements;
            break;

     default:

          statements;
          break;

}

 

The try statement try
{

       statements;

}

catch( exception classes)
{

       statements;

}

 

 

 

 

 

 <Java 24><Home>