forked from scottnakada/HackerRank-Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution.java
More file actions
78 lines (59 loc) · 1.93 KB
/
Solution.java
File metadata and controls
78 lines (59 loc) · 1.93 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
Problem Statement
Welcome to Day 1! Check out the video tutorial here
(https://www.youtube.com/watch?v=XLCka0noTY4&feature=youtu.be), or just jump
right into the problem.
Let's talk about data types. In programming, a data type is a classification of types of
data that determine the possible values and operations on that particular type.
Some typical examples of data types are:
int
double
boolean
char
String
Array
Remember, in languages like Java data types (like the ones above) can be classified into two main groups:
Primitive Types
Reference Types
For this challenge, consider the following inputs (you don't need to read any input):
5.35
'a'
false
100
"I am a code monkey"
true
17.3
'c'
"derp"
For each line above, print out if it is an instance of a primitive or referenced type as
well as which data type it is (using the typical examples above).
Good luck!
Hint: In Java, String is a referenced type.
Output Format
Output nine lines. Print one line for each of the input given above in the following format:
MainDataTypeOfInstance : SpecificDataTypeOfInstance
For example, if the input is:
123
Your output should be:
Primitive : int
Make sure you spell everything correctly and capitalize your entries. Also,
don't forget spaces and colon in between the main and specific data types!
*/
public class Solution {
public void printVars() {
System.out.println("Primitive : double");
System.out.println("Primitive : char");
System.out.println("Primitive : boolean");
System.out.println("Primitive : int");
System.out.println("Referenced : String");
System.out.println("Primitive : boolean");
System.out.println("Primitive : double");
System.out.println("Primitive : char");
System.out.println("Referenced : String");
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Solution sol = new Solution();
sol.printVars();
}
}