-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStrings.java
More file actions
35 lines (35 loc) · 1.3 KB
/
Strings.java
File metadata and controls
35 lines (35 loc) · 1.3 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
public class S
{
public static void main(String[] args)
{
String str="Hello Java";
System.out.println("String"+str+"'");
//1.length()
System.out.println("Length"+str.length());
//2.trim()
System.out.println("trim()'"+str.trim()+"'");
//3.toUpperCase()
System.out.println("uppercase"+str.toUpperCase());
//4.toLowerCase()
System.out.println("lowercase"+str.toLowerCase());
//5.charAt()
System.out.println("index 2"+str.charAt(2));
//6.substring()
System.out.println("substring"+str.substring(2,7));
//7.contains()
System.out.println("contains"+str.contains("Java"));
//8.equals()
System.out.println("equals "+str.equals(" Hello Java "));
//9.equalsIgnoreCase()
System.out.println("equalsIgnoreCase "+str.equalsIgnoreCase(" hello java "));
//10.startsWith() and endsWith()
System.out.println("starts"+str.startsWith(" He"));
System.out.println("ends"+str.endsWith("va "));
//11.replace()
System.out.println("replace"+str.replace("Java","World"));
//12.indexOf()
System.out.println("Indexof'J'"+str.indexOf("J"));
//13.concat()
System.out.println("concat"+str.concat("programming"));
}
}