-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMethods.java
More file actions
35 lines (33 loc) · 1.68 KB
/
Copy pathMethods.java
File metadata and controls
35 lines (33 loc) · 1.68 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
package practice;
public class Methods {
public static void main(String[] args) {
String s="Navi b";
String s1="navi b";
System.out.println(s.equals(s1));
System.out.println(s==s1);
System.out.println(s.length()+" //length");
System.out.println(s.equalsIgnoreCase(s1)+" //ignore case");
System.out.println(s.compareTo(s1)+" //compare");
System.out.println(s.compareToIgnoreCase(s1)+" //compare & ignore case");
System.out.println(s.toUpperCase()+" //uppercase");
System.out.println(s.toLowerCase()+" //lowercase");
System.out.println(s+" // Immutable // ");
System.out.println(s.trim()+" //trim");
System.out.println(s.indexOf('i')+" //index of i");//index of i
System.out.println(s.indexOf("i",2)+" //after 2nd index");//after 2nd index
System.out.println(s.indexOf("a",1,3)+" //INBETWEEN INDEX");//inbetween index
System.out.println(s.contains("v")+" //checks if it is present");
System.out.println(s.contains("naveena")+" //checks");
System.out.println(s.substring(2)+" //gets from 2nd index");
System.out.println(s.substring(0,4)+" //gets the data inbetween index");
System.out.println(s.endsWith("b")+" //if ends returns true");
System.out.println(s.repeat(2)+" //repeating");
System.out.println(s.replace("Navi","naveena")+" //replace the char");
System.out.println(s.replaceFirst("Navi","Navee")+" //Replace 1st occurance");
System.out.println(s);
System.out.println(s.replaceAll("N","*")+" //Replaces the char or string");
System.out.println(s.replaceAll("[aeiou]","#")+" //It replaces all vowels to #");
System.out.println(s.split(" "));
System.out.println(s.concat(" navee"+" bbb"));
}
}