-
Notifications
You must be signed in to change notification settings - Fork 0
/
Java Datatypes
44 lines (40 loc) · 1.22 KB
/
Java Datatypes
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
42
43
44
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
int t=Integer.parseInt(scan.nextLine());
List<String> nos=new ArrayList<>();
while(scan.hasNextLine()){
nos.add(scan.nextLine());
}
for(String no:nos){
List<String> ans=new ArrayList<>();
try{
Byte.parseByte(no);
ans.add("* byte");
} catch(Exception e){}
try{
Short.parseShort(no);
ans.add("* short");
} catch(Exception e){}
try{
Integer.parseInt(no);
ans.add("* int");
} catch(Exception e){}
try{
Long.parseLong(no);
ans.add("* long");
} catch(Exception e){}
if(ans.isEmpty()){
System.out.println(no+" can't be fitted anywhere.");
}
else{
System.out.println(no+" can be fitted in:");
for(String an:ans){
System.out.println(an);
}
}
}
}
}