-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOperators.java
More file actions
24 lines (19 loc) · 880 Bytes
/
Operators.java
File metadata and controls
24 lines (19 loc) · 880 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
import java.util.ArrayList;
public class Operators {
public static void main(String[] args) {
System.out.println('a'+'b'); //195
System.out.println("a"+"b"); //ab
System.out.println('a');
System.out.println('a'+3);
System.out.println((char)('a'+3));
System.out.println("a"+3);
//integer will be converted into Integer that will call toString()
//this is as same as: "a"+"1"
//Obj always uses toString()
System.out.println("JD"+ new ArrayList<>()); //JD[]
System.out.println("JD"+new Integer(48)); //JD48
//+ can be used with any dtype, but anyone of them must be a string!
// System.out.println(new Integer(48)+new int[]{1,2,3}); //obj + obj fails
System.out.println(new Integer(48)+""+new int[]{1,2,3}); //obj +""+ obj pass. Result will be a string.
}
}