Computer Math - Strings
String one = "abcdefghijklm"; System.out.print( one.charAt(0) );
a
charAt(): a). x >= 0 b). x > 0
a
indexOf(): a). x >= 0 b). x > 0
a
String one = "abcdefghijklm"; System.out.print( one.substring(0,4) );
abcd
String one = "abcdefghijklm"; System.out.print( one.charAt(1));
b
length(): a). x >= 0 b). x > 0
b
String one = "abcdefghijklm"; System.out.print( one.substring(2,7));
cdefg
String one = "abcdefghijklm"; System.out.print( one.charAt(9) );
j
String one = "abcdefghijklm"; System.out.print( one.substring(9) );
jklm
String one = "abcdefghijklm"; System.out.print(one.charAt(one.length()-1));
m
String two = "01234567890"; System.out.print( two.indexOf("24"));
-1
String two = "01234567890"; System.out.print( two.indexOf('r'));
-1
String one = "abcdefghijklm"; System.out.print( one.indexOf("abc") );
0
String two = "01234567890"; System.out.print( two.indexOf('0'));
0
String two = "01234567890"; System.out.print( two.length());
11
String one = "abcdefghijklm"; System.out.print(one.length());
13
String three = "01 23 45 67 89 0"; System.out.print( three.length());
16
String one = "abcdefghijklm"; System.out.print( one.indexOf('c'));
2
String one = "abcdefghijklm"; System.out.print( one.indexOf("e") );
4
String two = "01234567890"; System.out.print( two.indexOf("56"));
5
String three = "01 23 45 67 89 0"; System.out.print( three.indexOf("45"));
6
String one = "abcdefghijklm"; System.out.print( one.indexOf("hij") );
7
String one = "abcdefghijklm"; System.out.print( one.substring(5) );
fghijklm
public char getFirstLetter( ) { }
return word.charAt(0);
public char getLastLetter( ) { }
return word.charAt(word.length()-1);
public String toString()
return word;
public LetterFun(String s) { }
setString(s);
public void setString(String s) { }
word = s;