forked from kotharigaurav6/itep5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrimitive1.java
41 lines (34 loc) · 1.07 KB
/
Primitive1.java
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
32
33
34
35
36
37
38
39
40
41
// program showing the concept of primitive type casting
class Primitive1
{
public static void main(String args[])
{
/* implicit type casting */
// int a = 10;
// double b = a;
// System.out.println("b : "+b);
/* explicit type casting */
//double a1 = 9090909090; //error : integer number too large
// double a1 = 9090909090.0;
// int b1 = (int)Math.round(a1);
// System.out.println("value : "+Math.round(a1));
// System.out.println("b1 : "+b1);
// int a = 1000;
// int b = 30;
// byte c = (byte)(a+b);
// System.out.println("c : "+c);
// short a1 = 32767;
// short a2 = 32767;
// byte c = (byte)(a1+a2);
// System.out.println("c : "+c);
// int a1 = 35000;
// short a2 = (short)a1;
// System.out.println("a2 : "+a2);
// double a1 = 2180909090.0;
// float b1 = (float)a1;
// System.out.println("b1 : "+b1);
// long a = 5050505050L;
// int b = (int)a;
// System.out.println("b : "+b);
}
}