Which extracts the first character of <code>String s = "hello";</code>?
- A
s.char(1)
- B
s[0]
- Ccheck_circle
s.charAt(0)
- D
s.first()
Explanation
<code>s.charAt(0)</code> returns <code>'h'</code> — strings are 0-indexed in Java.
AP Computer Science A· difficulty 4/5
Which extracts the first character of <code>String s = "hello";</code>?
s.char(1)
s[0]
s.charAt(0)
s.first()
Explanation
<code>s.charAt(0)</code> returns <code>'h'</code> — strings are 0-indexed in Java.
Want 10 more like this — adaptive to your weak spots?
Consider: <code class="language-java"String s = "ABCDE"; String t = s.substring(2, 2) + s.substring(1, 4) + s.substring(5); System.out.print("[" + t + "]"); </c…
chevron_right<code"a,b,c".split(",")</code returns…
chevron_right<code"hi".charAt(2)</code causes…
chevron_right