-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImportant String Methods
More file actions
41 lines (25 loc) · 1009 Bytes
/
Important String Methods
File metadata and controls
41 lines (25 loc) · 1009 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
41
import java.lang.*;
import java.io.*;
import java.util.*;
// String important functions
public class UdemyClasses
{
public static void main(String args[])
{
String name = "Paras Bhatt";
String ForTrim = " TRIM ";
int a = name.length();
System.out.println(name.concat(" is a good boy!")); //concat()
System.out.println(name.toUpperCase()); //toUpperCase()
System.out.println(name.toLowerCase()); //toLowerCase()
System.out.println(ForTrim.trim().concat(" successfully trimed!!!")); //trim()
System.out.println(a); //length()
System.out.println(name.replace("Paras","Krishna")); //replace()
System.out.println(name.substring(2,7)); //substring()
System.out.println(name.isEmpty()); //isEmpty()
System.out.println(name.startsWith("Paras")); //startsWith()
System.out.println(name.endsWith("Paras")); //endsWith()
System.out.println(name.indexOf("s")); //indexOf()
System.out.println(name.charAt(4)); //charAt()
}
}