forked from rahulXbarnwal/JavaTutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVariables.java
More file actions
29 lines (20 loc) · 730 Bytes
/
Variables.java
File metadata and controls
29 lines (20 loc) · 730 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
public class Variables {
public static void main(String[] args) {
boolean isPassed = true;
long count = 12;
int countInt = (int)count;
byte marks = 13;
short studentsCount = 1235;
float pi = 3.14f;
double secondPi = 3.143213241123; // will print all precision
float x = 3.143213241123f; // will print till 7 decimal points
System.out.println(pi);
System.out.println(secondPi);
System.out.println(x);
char myLetter = 'a';
System.out.println(myLetter);
int age = 128;
byte newAge = (byte)age; // explicit typecasting, lossy conversion
System.out.println(newAge); // -128 -> rotation
}
}