-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringMethods.java
More file actions
57 lines (38 loc) · 1.41 KB
/
Copy pathStringMethods.java
File metadata and controls
57 lines (38 loc) · 1.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
public class StringMethods {
public static void main(String[] args) {
//CREATING STRING
String s= "System Design";
String s1= "System design";
String s2= " Java ";
//charAt()
System.out.println(s.charAt(7)); //m
//compareTo()
System.out.println(s.compareTo(s1)); //-32
//concat()
System.out.println(s.concat(" Concept")); //System Design Concept
//contains()
System.out.println(s.contains("Des")); //true
//endsWith()
System.out.println(s.endsWith("s")); //false
//equals()
System.out.println(s.equals(s1)); //false
//equalsIgnoreCase()
System.out.println(s.equalsIgnoreCase(s1)); //true
//indexOf()
System.out.println(s.indexOf('t')); //3
//substring()
System.out.println(s.substring(3)); //tem Design
System.out.println(s.substring(4, 11)); //em Desi
//length()
System.out.println(s.length()); //13
//replace()
System.out.println(s.replace('e', 'o')); //Systom Dosign
//toLowerCase()
System.out.println(s.toLowerCase()); //system design
//toUpperCase()
System.out.println(s.toUpperCase()); //SYSTEM DESIGN
//trim()
System.out.println(s2);
System.out.println(s2.trim() + " language");
}
}