File tree Expand file tree Collapse file tree 3 files changed +38
-0
lines changed
src/com/codefortomorrow/beginner/chapter3 Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ public class StringSlicer{
2
+ public static
3
+ }
Original file line number Diff line number Diff line change
1
+ public class StringSlicer {
2
+ /*
3
+ Use String Methods to convert the following strings to the results
4
+ a) "A Tale of Two Cities" -> "WO CIT"
5
+ b) "A Handmaid's Tale" -> "s"
6
+ c) "wE LoVe tO CoDe" -> "we love to cod"
7
+ */
8
+ public static void main (String [] args ){
9
+
10
+ }
11
+ }
Original file line number Diff line number Diff line change
1
+ public class StringSlicer {
2
+ /*
3
+ Use String Methods to convert the following strings to the results
4
+ a) "A Tale of Two Cities" -> "WO CIT"
5
+ b) "A Handmaid's Tale" -> "s"
6
+ c) "wE LoVe tO CoDe" -> "e love to code"
7
+ */
8
+ public static void main (String [] args ){
9
+ //Initialize original strings
10
+ String s1 = "A Tale of Two Cities" ;
11
+ String s2 = "A Handmaid's Tale" ;
12
+ String s3 = "wE LoVe tO CoDe" ;
13
+
14
+ //Use substring + uppercase on the first one
15
+ System .out .println (s1 .toUpperCase ().substring (11 ,17 ));
16
+
17
+ //Use charAt for s2
18
+ System .out .println (s2 .charAt (11 ));
19
+
20
+ //Use the single-argument substring + lowercase
21
+ System .out .println (s3 .toLowerCase ().substring (1 ));
22
+ //You can also use substring(1,13)
23
+ }
24
+ }
You can’t perform that action at this time.
0 commit comments