-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStringFunctions.java
More file actions
86 lines (67 loc) · 2.41 KB
/
StringFunctions.java
File metadata and controls
86 lines (67 loc) · 2.41 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
package strings;
public class StringFunctions {
public static void main(String[] args) {
String str1 = "My name is Subhakanta Roul";
String str2 = "MY NAME IS SUBHAKANTA ROUL";
String str3 = "my name is subhakanta roul";
String str4 = "Mississippi";
System.out.println(str1.charAt(4));
System.out.println(str2.equalsIgnoreCase(str3));
System.out.println(str1.indexOf('a'));
System.out.println(str1.indexOf('a', 6));
System.out.println(str4.indexOf("iss"));
System.out.println(str4.indexOf("iss", 5));
System.out.println(str4.length());
String str5 = "";
System.out.println(str5.length());
System.out.println(str4.replace('s', 'z'));
System.out.println(str4.replace("iss", "zy"));
System.out.println(str1.substring(5));
System.out.println(str2.substring(3, 9));
System.out.println(str2.toLowerCase());
System.out.println(str3.toUpperCase());
int i = 5;
StringFunctions stf = new StringFunctions();
String str6 = String.valueOf(i);
System.out.println(str6);
String str7 = String.valueOf(stf);
System.out.println(str7);
System.out.println(String.valueOf(stf).getClass().getName());
StringFunctions stfc = new StringFunctions();
System.out.println(stfc);
System.out.println(stfc.toString());
System.out.println(str4.trim());
System.out.println(str4.contains("ssp"));
System.out.println(str1.toLowerCase().contains(str2.toLowerCase()));
System.out.println(str1.endsWith("a Roul"));
byte b[] = str1.getBytes();
for (int j = 0; j < b.length; j++) {
System.out.print((char) b[j]);
}
System.out.println();
char[] ch = new char[10];
str1.getChars(0, 10, ch, 0);
System.out.println(ch);
System.out.println(str1.isEmpty());
String str8 = "";
String str9 = " ";
System.out.println(str8.isEmpty());
// the isBlank() is a java 11 method to check blank strings
// returns true even is there are blank spaces. i.e it does not consider the blank spaces.
// System.out.println(str8.isBlank());
System.out.println(str9.isEmpty());
// System.out.println(str9.isBlank());
System.out.println(String.join(":", "26", "1", "2021"));
System.out.println(String.join(":", "10", "51", "PM"));
System.out.println(str1.startsWith("n", 3));
System.out.println(str1.startsWith("My"));
String str10[] = str1.split("a");
for (String s : str10) {
System.out.println(s);
}
}
@Override
public String toString() {
return "hi you are hacked!!lol";
}
}