-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest_Random.java
More file actions
167 lines (126 loc) · 3.12 KB
/
Test_Random.java
File metadata and controls
167 lines (126 loc) · 3.12 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
package com.newTest;
import java.util.HashSet;
import java.util.Set;
public class Test_Random
{
//parse ; toString() ; valueOf()
public static void random()
{
String i = Integer.toString(1);
int parse = Integer.parseInt(i);
String v = String.valueOf(1);
Float f = 1.5F;
String s = Float.toString(Float.valueOf(1.9F));
System.out.println(s);
long l = Long.parseLong("12578678");
Float.parseFloat("1.5F");
Integer.parseInt("12");
Double.parseDouble("1.55D");
boolean b = Boolean.parseBoolean("true");
Long.valueOf(115768);
Float.valueOf(1.5F);
Integer.valueOf(1);
Double.valueOf(1.5D);
Boolean bb = Boolean.valueOf(true);
String LL = Long.toString(12346);
String F = Float.toString(1.5F);
String D = Double.toString(1.6D);
Long klj= 1547658L;
klj.floatValue();
klj.doubleValue();
klj.intValue();
Integer intj = 12 ;
float fl = intj.floatValue();
long ln = intj.longValue();
String srty = new String("abc");
Character.toString('c');
System.out.println("***check random assignment***");
int ity= 'c';
char ch = 81 ;
System.out.println("Print int value:- "+ity);
System.out.println("Print char value:- "+ch);
}
public static void convertString()
{
String s = "aab;ccd;eef";
String[] strAr = s.split(";");
for(String s1: strAr)
{
Set<Character> setT = new HashSet<>();
char ch[] = new char[s1.length()] ;
int k= 0;
String stt = "";
for(int i=0 ; i<s1.length() ;i++)
{
setT.add(s1.charAt(i));
}
System.out.println("set object:- "+setT);
for(char chrr :setT)
{
stt +=chrr;
}
//String newstr = new String(ch);
System.out.println("Print string:- "+stt);
}
}
public static void convertString2()
{
String s = "aab;ccd;eef";
String[] strAr = s.split(";");
for(String s1: strAr)
{
Set<Character> setT = new HashSet<>();
char ch[] = new char[s1.length()-1] ;
int k= 0;
String stt = "";
for(int i=0 ; i<s1.length() ;i++)
{
setT.add(s1.charAt(i));
}
System.out.println("set object:- "+setT);
for(char c:setT)
{
ch[k++] = c ;
}
//String newstr = new String(ch);
System.out.println("Print string:- "+new String(ch));
}
}
public static void test2()
{
Integer i = 20 ;
int j= i;
System.out.println(j);
}
public static void test123()
{
if("string".toUpperCase() == "STRING")
{
System.out.println("str");
}
else
System.out.println("none");
}
public static void test_increment_decrement()
{
int i= 0 ;
for(; i<5 ; i++)
{
System.out.println(i);
}
int j=0;
while(j<6)
{
j+=2; //increments by 2
System.out.println("print j:- "+j);
}
}
public static void main(String[] args)
{
//random();
//convertString2();
//test2();
//test123();
test_increment_decrement();
}
}