-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathConvertToString.java
More file actions
45 lines (31 loc) · 928 Bytes
/
Copy pathConvertToString.java
File metadata and controls
45 lines (31 loc) · 928 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
35
36
37
38
39
40
41
42
43
package Concept;
public class ConvertToString
{
public static void main(String args[])
{
ConvertToString cts= new ConvertToString();
cts.firstWay();
cts.secondWay();
cts.thirdWay();
}
public void firstWay() {
int a = 1234;
int b = -1234;
String str1 = Integer.toString(a);
String str2 = Integer.toString(b);
System.out.println("String str1 - first way -" + str1);
System.out.println("String str2 - first way -" + str2);
}
public void secondWay() {
int c = 1234;
String str3 = String.valueOf(c);
System.out.println("String str3 - second way -" + str3);
}
public void thirdWay() {
int d = 1234;
@SuppressWarnings("removal")
Integer obj = new Integer(d);
String str4 = obj.toString();
System.out.println("String str4 - third way -" + str4);
}
}