Quote:
Originally Posted by Kuriin # Input a text string, output its length; input an index within the string, and output the character at that position in the string; input another text string, and output the location of the first occurrence of the second string in the first one (if such location exists, otherwise output -1); |
To input a string just use: keyboard.nextString()
To output its length it'd be like:
Code:
str1 = keyboard.nextString();
str1.length();
To output the character at an index, use charAt(i)
gives you the value at the index "i"
And to output the first occurrence of a char in str1, use indexOf(char)
gives you the index of first occurrence of the character "char"