-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLiteral.java
More file actions
60 lines (36 loc) · 1.37 KB
/
Literal.java
File metadata and controls
60 lines (36 loc) · 1.37 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
public class Literal {
public static void main(String[] args) {
int x = 10; // here 10 is literal
// decimal literal
int y =10;
//octal form
int z = 010;
//hexa decimal form
int a = 0x10; // i know java is case sensitive but in some cases it is not ,this is the example of java not being case sensitive
//you can x or X it does not matter
int b = 0xface ;
int c = 0xbeef;
// int d = 0xbeer ; wrong r can not be a part of hexadecimal form
int d = 10;
int e = 010;
int f =0x10;
System.out.println(d+e+f);
// print statement will always change format to decimal form
// output 10 +8 +16 = 34
long g = 0x10l;
double h = 01.1 ;//what will java consider it 1.1 or a octal double
//it will consider double
double i = 1.2e3;
// char range is 0 to 65535
char ch =97;//output a
char ch1 = 0xface ;
char ch2 = '\u0061'; // char can also be defined like this number are in the form hexa decimal
// every escape character is a char
char ch3 = '\n';
// binary literal came after 1.7v
int bi = 0b111;
// underscore is used for readability
double dd =1_23_4;
// underscore cannot be on last ,first and before decimal
}
}