forked from DavidsonCodes/Java_Sample_Codes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrimitiveTypes.java
More file actions
35 lines (31 loc) · 1.18 KB
/
Copy pathPrimitiveTypes.java
File metadata and controls
35 lines (31 loc) · 1.18 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
package Online_Code_Samples.Week1;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Scanner;
public class PrimitiveTypes {
public static void main(String[] args) {
System.out.print("Please type the word \"string\" in the prompt: ");
String aString;
Scanner scanner = new Scanner(System.in);
aString = scanner.next();
int anInt = 1000;
boolean booleanValue = (aString.equals("string"));
char charValue = 'A';
double doubleValue = 1.50;
float floatValue = 2000F;
long longValue = 3445495996L;
short shortValue = 12900;
byte byteValue = 127;
System.out.println(anInt);
System.out.println(Arrays.toString(aString.getBytes(StandardCharsets.UTF_16BE)));
System.out.println(Arrays.toString(aString.getBytes()));
System.out.println(aString.repeat(3));
System.out.println(booleanValue);
System.out.println(charValue);
System.out.println(doubleValue);
System.out.println(floatValue);
System.out.println(longValue);
System.out.println(shortValue);
System.out.println(byteValue );
}
}