-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMain.java
More file actions
34 lines (24 loc) · 986 Bytes
/
Main.java
File metadata and controls
34 lines (24 loc) · 986 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
30
31
32
33
34
package ByteShortInt;
public class Main {
public static void main(String[] args) {
//Since Java 1.7 you can use underscores to make large numbers more readable
//byte has a width of 8
byte myByteMinValue = -128;
byte myByteMaxValue = 127;
//short has a width of 16
short myShortMinValue = -32768;
short myShortMaxValue = 32767;
//int has a width of 32
int myIntMinValue = -2_147_483_648;
int myIntMaxValue = 2_147_483_647;
//long has a width of 64
long myLongMinValue = -9_223_372_036_854_775_808L;
long myLongMaxValue = 9_223_372_036_854_775_807L;
//Challenge
byte myByteValue = 10;
short myShortValue = 20;
int myIntValue = 50;
long myLongValue = 50000L + 10L * (myByteValue + myShortValue + myIntValue);
System.out.println("My long value equation is equal to " + myLongValue);
}
}