JAVA


Java data types

Type Size Description
byte 1 Byte Signed Integer, between -128 and +127
short 2 Bytes Signed Integer, between -32768 and +32767
int 4 Bytes Signed Integer, between (-231) and (231-1)
long 8 Bytes Signed Integer, between (-263) and (263-1)
float 4 Bytes Single-precision floating point
double 8 Bytes Double-precision floating point
char 2 Bytes Unicode character
boolean 1 Bit Boolean value (true, false)

Java Operators

  Operator UseDescription  + op1 + op2 Adds op1 and op2 - op1 - op2 Subtracts op2 from op1 * op1 * op2 Multiplies op1 by op2 / op1 / op2 Divides op1 by op2 % op1 % op2 Computes the remainder of op1/op2   + + opA positive value - - opNegates op   >> op1 >> op2Right shift of op1's bits for op2 positions  << op1 << op2 Left shift of op1's bits for op2 positions>>>op1 >>> op2 Right shift of op1's bits for op2 positions (without sign)  &op1 & op2 Bitwise and  |op1 | op2 Bitwise or  ^op1 ^ op2 Bitwise xor   ~~ opBitwise complement   ++ op ++ Add 1 to op; evaluates to value before incrementing  ++ ++ op Add 1 to op; evaluates to value after incrementing  -- op -- Subtract 1 from op; evaluates to value before  -- -- op Subtract 1 from op; evaluates to value after   Operator UseReturn true if   >op1 > op2 op1 is greater than op2  >= op1 >= op2op1 is greater than or equal to op2    

If-else

 if (expression) statement1 (*) else statement2 (*) 
If expression is true, executes statement1 (*), else executes statement2 (*).   

While

 while (expression) statement (*) 
Until expression is true, executes statement (*). 

For

 for (initialization; termination; increment) statement (*) 
The for statement is used for loop control; initialization initialize the loop,termination is the expression that ends the loop, and increment is the expression executed after every iteration. Ex. 
 for (int i = 1; i <= 10; i++){ System.out.println(i); } 
writes integers from one to ten on standard output.

Note *

Statement can be a single statement or a block of statements enclosed in curly brackets ({, }).


Index           Home  Back       About  Contact us!

Copyright (c) 1998-2006 Wowarea