For you to do:
(the output should be one per line)
-
Print out the position of the first occurrence of "c"
-
Print out the position of the first occurrence of " "
-
Print out the position of the first occurrence of the variable target1
-
Print out the position of the first occurrence of the variable target2
class Main {
public static void main(String[] args) {
String str = "abracadabra alakazam";
String target1 = "dab";
String target2 = "ABRA";
System.out.println(str.indexOf("c"));
System.out.println(str.indexOf(" "));
System.out.println(str.indexOf(target1));
System.out.println(str.indexOf(target2));
}
}
반응형
'Java_beginner(Repl.it) > Auto-Graded-Course(AP CS A)' 카테고리의 다른 글
010 - String Methods Practice 1 (0) | 2019.11.26 |
---|---|
009 - String Methods - substring (0) | 2019.11.26 |
007 - String Methods - charAt (0) | 2019.11.26 |
006 - String Methods - Length (0) | 2019.11.26 |
005 - Creating Variables and Printing 5 (0) | 2019.11.26 |