-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathStringMethods.java
More file actions
44 lines (40 loc) · 901 Bytes
/
StringMethods.java
File metadata and controls
44 lines (40 loc) · 901 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
42
43
44
public class StringMethods {
public static void main(String[] args) {
String x= "Hello";
String y = "Hello";
String z = "HELLO";
System.out.println(x.length());
System.out.println(x.toUpperCase());
String text ="Hello How are You Hello";
//int index = text.indexOf("Hello");
int index = text.lastIndexOf("Hello");
System.out.println("Index is "+index);
if(index>=0){
System.out.println("Found...");
}
else
{
System.out.println("Not Found...");
}
if(x.equalsIgnoreCase(z)){
System.out.println("Same Value With EqualsIgnoreCase...");
}
else
{
System.out.println("Not Same Value with EqualsIgnoreCase...");
}
if(x.equals(y)){
System.out.println("Same Value");
}
else{
System.out.println("Not Same Value");
}
if(x==x.toUpperCase()){
System.out.println("Same Ref");
}
else
{
System.out.println("Not Same Ref");
}
}
}