Core java
Data Types
data_type identifier;
int a;
Primitive Type
byte
short
int
long
char
float
double
boolean
Reference Type
class
Array
String
etc.
Type Size Range
byte 1 bytes -128 to +127
short 2 bytes -32768 to +32767
int 4 bytes -2^31 to +2^31-1
long 8 bytes -2^63 to +2^63-1
char 2 bytes 0 to 65535
float 4 bytes +- 3.40282347E+38F
double 8 bytes +- 1.79769313486231570E+308
boolean 1 bit true/false
Datatypes Example:->
public class DataTypesDemo {
public static void main(String[]
args) {
byte a = -50;
short b = 150;
int c = 10000;
long d = 100000;
char e='A';
float f= 1.23f;
double g = 12345.6789;
byte h =20;
byte result = (byte) (a+h);
}
}
Comments
Post a Comment