View Single Post
Old 09-28-2007, 09:21 PM   #35 (permalink)
Neph
Late to the party
 
Join Date: Nov 2006
Location: Maryland
Posts: 674
+0 Internets
Quote:
Originally Posted by Kuriin View Post
# 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)
Code:
str1.charAt(i)
gives you the value at the index "i"

And to output the first occurrence of a char in str1, use indexOf(char)
Code:
str1.indexOf(char)
gives you the index of first occurrence of the character "char"
Neph is offline   Reply With Quote

 
Uberguilds Network