Skip to content

Instantly share code, notes, and snippets.

@viveknarang
Created February 5, 2018 22:43
Show Gist options
  • Save viveknarang/4742a658b825f4511a5042b6bc8c43c5 to your computer and use it in GitHub Desktop.
Save viveknarang/4742a658b825f4511a5042b6bc8c43c5 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class CharMatching {
public static void main (String [] args) {
String userInput = "";
char firstLetter = '-';
userInput = "banana";
firstLetter = 'b';
if (userInput.charAt(0) == firstLetter) {
System.out.println("Found match: " + firstLetter);
}
else {
System.out.println("No match: " + firstLetter);
}
return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment