-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdataTypes.java
More file actions
31 lines (23 loc) · 778 Bytes
/
dataTypes.java
File metadata and controls
31 lines (23 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
public class dataTypes{
static public void main(String[] name){
byte a = 123;
short b = 12345;
int c = 1234567890;
long d = 1234567890123456789L;
float e = 0.12345678f;
double f = 0.12345678901234345;
char g = 'A';
boolean h = true;
float i = 12e3f;
double j = 34E5F;
System.out.printf("%d %d %d %d %f %f %.14f %c %b %e %e \n",a,b,c,d,e,f,f,g,h,i,j);
//widening casting (implicit-type casting)
int myInt = 6;
double myDouble = myInt;
System.out.println(myDouble);
//narrow casting (explicit-type casting)
double myDoub = 45.67;
int myIn = (int) myDoub;
System.out.print(myIn);
}
}