Default value of all Variables
Type of variable Default value
byte 0
short 0
int 0
long 0L
float 0f
double 0d
char null
boolean false
reference null
Numeric primitives values
Type of variable Bits Bytes
byte 8 1
short 16 2
int 32 4
long 64 8
float 32 4
double 64 8
Backslash Character Constants
Constant Meaning
\b back space
\f form feed
\n new line
\r carriage return
\t horizontal tab
'\ " single quote
'\ " ' double quote
'\ \ ' backslash
Arithmetic Operators
Operator Meaning
+ Addition or plus
- Subtraction or minus
* Multiplication
/ Division
% Modulo division
Relational Operators
Operator Meaning
> is greater than
<= is less than or equal to
>= is greater than or equal to
== is equal to
!= is not equal to
Logical Operators
Operator Meaning
&& logical AND
|| logical OR
! logical NOT
Casts that you can use which are No Loss of Imformation (you can find out about explanation of"casting" in my post)
From To
byte short char int long float double
short int long float double
char int long float double
int long float double
long float double
float double
Check out below Example program using all above variables and operators
public class Example {
/**
* @param args
*/
public static void main(String[] args) {
float a = 50.55f;
double b = 98.078d;
long c = 1234;
System.out.println("a = "+a);
System.out.println("b = "+b);
System.out.println("c = "+c);
System.out.println(" \n");
System.out.println("a <b "+ (a<b));
System.out.println("a>b "+(a>b));
System.out.println("a!=c "+(a!=c));
System.out.println("b=a+c \n"+(b ==a+c));
System.out.println(" ");
System.out.println("a<b && b>c "+ (a<b && b>c));
System.out.println("a!b "+(a!=b));
}
}
___________________________________________
Output:
a = 50.55
b = 98.078
c = 1234
a <b true
a>b false
a!=c true
b=a+c
false
a<b && b>c false
a!b true
__________________________________________
Java Packages
java.lang - basic language functionality and fundamental types
Output:
a = 50.55
b = 98.078
c = 1234
a <b true
a>b false
a!=c true
b=a+c
false
a<b && b>c false
a!b true
__________________________________________
Java Packages
java.lang - basic language functionality and fundamental types
java.util - collection data structure classes
java.io - file operation
java.math - multiprecision arithmetic
java.nio - file operation
java.net - networking operation, sockets, DNS lokups
java.security - key generation, encryption and decryption
java.sql - Java database connectivity (JDBC) to access database
java.awt - basic hierarchy of packages for native GUI components
javax.swing - hierarchy of packages for platform independent rich GUI component
java.applet - classes for creating an applet
java.io - file operation
java.math - multiprecision arithmetic
java.nio - file operation
java.net - networking operation, sockets, DNS lokups
java.security - key generation, encryption and decryption
java.sql - Java database connectivity (JDBC) to access database
java.awt - basic hierarchy of packages for native GUI components
javax.swing - hierarchy of packages for platform independent rich GUI component
java.applet - classes for creating an applet
No comments:
Post a Comment