Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

Β 

History

History
History
32 lines (24 loc) Β· 820 Bytes

File metadata and controls

32 lines (24 loc) Β· 820 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
package practice;
public class Literal {
public static void main(String[] args) {
byte b1 = 10; // decimal
byte b2 = 0b1010; // binary
byte b3 = 012; // octal
byte b4 = 0XA; // hexadecimal
System.out.println(b1); // 10
System.out.println(b2); // 10
System.out.println(b3); // 10
System.out.println(b4); // 10
// long val = 999999999999; // The literal 999999999999 of type int is out of range
long val = 999999999999L;
System.out.println(val); // 999999999999
// for readability purpose we can use underscore to seperate large numbers
long value = 999_999_999_999L;
System.out.println(value); // 999999999999
// float f = 12.42; // Type mismatch: cannot convert from double to float
float f = 12.42f;
double d = 12.53d;
System.out.println(f);
System.out.println(d);
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.