Check first character of a word

Check first character of a word

Write a method to check if the first character of a word is equal to the letter ‘s’. Return “True” if it is and “False” if it isn’t. (HINT: Use the charAt method)

Example 1:


input data:
sign
output:
True

Example 2:


input data:
garage
output:
False
View Code Template
View Java Solution

Seda
Seda Kunda is a web designer and developer with a degree in Computer Science and a great passion for code. Besides code, she enjoys pepperoni pizza, watching the bachelor and sleeping in on Saturdays.
Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

2 thoughts on “Check first character of a word

  1. public static void CheckFirst(String st) {
    String firstchar = st.charAt(0);
    if(firstchar == “s”){
    System.out.printf(“This is really true”)}else{
    Syste.out.printf(“This is really false”); }
    }

Comments are closed.