For you to do:
(all output should be one per line)
-
On line 6, write a print statement that prints out a substring of str starting at index 5 and going to the end
-
On line 7, write a print statement that prints out a substring of str starting at index 7 and ending at index 10
-
On line 10, fill in the () in substring so that it prints "harambe"
-
On line 11, fill in the () in substring so that it prints "t f"
class Main {
public static void main(String[] args) {
String str = "laptops out for harambe";
//write code below
System.out.println(str.substring(5));
System.out.println(str.substring(7,10));
//fill in the blanks below:
System.out.println(str.substring(16)); //fill in substring so it prints "harambe"
System.out.println(str.substring(10,13)); //fill in substring so it prints "t f"
}
}
반응형
'Java_beginner(Repl.it) > Auto-Graded-Course(AP CS A)' 카테고리의 다른 글
011 - String Methods Practice 2 (0) | 2019.11.26 |
---|---|
010 - String Methods Practice 1 (0) | 2019.11.26 |
008 - String Methods - indexOf (0) | 2019.11.26 |
007 - String Methods - charAt (0) | 2019.11.26 |
006 - String Methods - Length (0) | 2019.11.26 |