Skip to content

Commit dfcffe0

Browse files
Some other methods of string
1 parent a16f8cf commit dfcffe0

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

String_2.java

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
package basicjava;
3+
4+
public class String_2 {
5+
public static void main(String[] args) {
6+
String firstName = "Susmoy";
7+
String lastName = " Barman";
8+
9+
// Now we will add two strings.
10+
String fullName = firstName + lastName;
11+
System.out.println("FullName is: "+fullName);
12+
13+
// another method ot add two string.
14+
fullName = firstName.concat(lastName);
15+
System.out.println("FullName is: "+fullName);
16+
17+
String upperName = fullName.toUpperCase();
18+
System.out.println("upperName: "+upperName);
19+
20+
String lowerName = fullName.toLowerCase();
21+
System.out.println("upperName: "+lowerName);
22+
23+
boolean b = firstName.startsWith("S");
24+
System.out.println("The value of b: "+b);
25+
26+
boolean c = lastName.endsWith("A");
27+
System.out.println("The value of c: "+c);
28+
29+
String[] s = {"susmoy","barman","tiash","cse","ru"};
30+
31+
//For each loop
32+
for(String x: s){
33+
System.out.print(" "+x);
34+
}
35+
System.out.println();
36+
for (int i = 0; i < 5; i++) {
37+
System.out.print(" "+s[i]);
38+
}
39+
System.out.println();
40+
}
41+
}

0 commit comments

Comments
 (0)