forked from naveenanimation20/JavaSessionsCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWrapperClass.java
More file actions
40 lines (26 loc) · 795 Bytes
/
WrapperClass.java
File metadata and controls
40 lines (26 loc) · 795 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
package JavaSessions;
import java.util.ArrayList;
public class WrapperClass {
public static void main(String[] args) {
//1. String to int :
String x = "100";
System.out.println(x+20);
int i = Integer.parseInt(x); //100
System.out.println(i+20);
// String h = "100A";
// int g = Integer.parseInt(h);
// System.out.println(g);//NumberFormatException: For input string: "100A
//2. String to double:
String y = "12.33";
System.out.println(y+20);
double d = Double.parseDouble(y);
System.out.println(d+10.22);
//3. int to String:
int k = 100;
System.out.println(k+20);
String p = String.valueOf(k); //"100"
System.out.println(p+20);
String tr = "your total amount is : 500";
ArrayList<Integer> ar = new ArrayList<Integer>();
}
}