End of preview
Upload your study docs or become a member.
Unformatted text preview:CHALLENGE
ACTIVITY
3.10.2: Looking for characters.
V
Write an expression to detect that the first character of userInput matches firstLetter.
import java . util . bcanner;
v
public class CharMatching {
1 test
public static void main (String args) {
passed
Scanner sonr = new Scanner (System. in) ;
String user Input;
v
All tests
8
char firstletter;
passed
g
userInput = sonr . nextLine();
10
firstLetter = scor . nextLine(). charAt(0);
11
12
if (/* Your solution goes here */ userInput. charAt(0) == firstletter) {
13
System. out. println( "Found match: " + firstLetter);
14
15
else {
16
System. out . printIn ("No match: " + firstLetter);
17
18
19
return;
20
21 }
Run