- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJavaDataTypes.java
More file actions
Latest commit
36 lines (28 loc) · 1.04 KB
/
Copy pathJavaDataTypes.java
File metadata and controls
36 lines (28 loc) · 1.04 KB
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
packageIntroduction;
importjava.util.*;
publicclassJavaDataTypes {
publicstaticvoidmain(String[] args) {
Scannerscan = newScanner(System.in);
Strings;
longnumber;
for (intx = 0, query = scan.nextInt(); x < query; x++) {
s = scan.next();
try {
number = Long.parseLong(s);
System.out.println(s + " can be fitted in:");
if (number >= Byte.MIN_VALUE && number <= Byte.MAX_VALUE) {
System.out.println("* byte");
}
if (number >= Short.MIN_VALUE && number <= Short.MAX_VALUE) {
System.out.println("* short");
}
if (number >= Integer.MIN_VALUE && number <= Integer.MAX_VALUE) {
System.out.println("* int");
}
System.out.println("* long");
} catch (Exceptionexcpetion) {
System.out.println(s + " can't be fitted anywhere.");
}
}
}
}