-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstring_methods.java
58 lines (51 loc) · 2.45 KB
/
string_methods.java
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
58
public class string_methods
{
public static void main(String args[]){
String s1="Football";
String s2="Shootball";
if((s1.compareTo(s2))==0)
System.out.println("The two strings are equal");
else if((s1.compareTo(s2))<0)
System.out.println(s1+"......"+s2);
else
System.out.println(s2+"......"+s1);
String s3=("Now is the time to be happy for all the good people");
System.out.println("indexOf('t'):"+s3.indexOf('t'));
System.out.println("indexOf('the'):"+s3.indexOf("the"));
String s4=("Now is the time to be happy for all the good people");
System.out.println("lastIndexOf('t'):" +s4.lastIndexOf('t'));
System.out.println("lastIndexOf('the'):"+s4.lastIndexOf("the"));
String s5="Now is the time to be happy for all the good people";
System.out.println("Length:"+s5.length());
String s6="Hello";
System.out.println("Replaced String:" +s6.replace('H','Y'));
String s7="Now is the time to be happy for all the good people";
System.out.println(s7.substring(7));
System.out.println(s7.substring(7,27));
String s8="Hello";
System.out.println(s8.toLowerCase());
System.out.println(s8.toUpperCase());
String s9=" Hello class ";
System.out.println(s9.trim());
System.out.println("isLowerCase:"+Character.isLowerCase('D'));
System.out.println("isLowerCase:"+Character.isLowerCase('f'));
System.out.println("isUpperCase:"+Character.isUpperCase('D'));
System.out.println("isUpperCase:"+Character.isUpperCase('f'));
System.out.println("isLetter:"+Character.isLetter('c'));
System.out.println("isLetter:"+Character.isLetter('5'));
System.out.println("isDigit:"+Character.isDigit('c'));
System.out.println("isDigit:"+Character.isDigit('5'));
System.out.println("isLetterOrDigit():"+Character.isLetterOrDigit(0*0041));
System.out.println("isLetterOrDigit():"+Character.isLetterOrDigit(0*0036));
System.out.println("isLetterOrDigit():"+Character.isLetterOrDigit(0*0024));
}
}
/*
👋 Hi, I’m @aarushinair - Aarushi Nair (she/her/ella)
👀 I’m a Computer Science Engineering Student
💞️ I’m looking to collaborate on #java, #python, #R, #applicationdevelopment
🌱 #GirlsWhoCode #WomenInTech #WomenInIT #WomenInSTEM #CyberSecurity #QuantumComputing #BlockChain #AI #ML
📫 How to reach me: https://www.linkedin.com/in/aarushinair/
👩🏫 YouTube Channel - Code with Aarushi : https://www.youtube.com/channel/UCKj5T1ELHCmkGKujkpqtl7Q
🙋 Follow me on Twitter: https://twitter.com/aarushinair_
*/