Unit 6 If/Else/Strings
hey thar
String sam = "hey there"; String ben = "hey thar"; ben.replaceAll('e', '#') out.println( ben.replaceAll("#", "-") );
7
String sam = "hey there"; String ben = "hey thar"; out.println( ben.compareTo("abc") );
-4
String sam = "hey there"; String ben = "hey thar"; out.println( ben.compareTo(sam) );
6
String sam = "hey there"; String ben = "hey thar"; out.println( ben.indexOf("ar") );
5
String sam = "hey there"; String ben = "hey thar"; out.println( ben.indexOf("ha") );
2
String sam = "hey there"; String ben = "hey thar"; out.println( ben.indexOf('y') );
8
String sam = "hey there"; String ben = "hey thar"; out.println( ben.length( ) );
h#y thar
String sam = "hey there"; String ben = "hey thar"; out.println( ben.replaceAll('e', '#') );
ERROR, Index out of bounds
String sam = "hey there"; String ben = "hey thar"; out.println( sam.charAt( 10 ) );
e
String sam = "hey there"; String ben = "hey thar"; out.println( sam.charAt(1) );
4
String sam = "hey there"; String ben = "hey thar"; out.println( sam.compareTo(ben) );
false
String sam = "hey there"; String ben = "hey thar"; out.println( sam.equals(ben) );
1
String sam = "hey there"; String ben = "hey thar"; out.println( sam.indexOf("ey") );
-1
String sam = "hey there"; String ben = "hey thar"; out.println( sam.indexOf('7') );
0
String sam = "hey there"; String ben = "hey thar"; out.println( sam.indexOf('h') );
9
String sam = "hey there"; String ben = "hey thar"; out.println( sam.length( ) );
-32
String sam = "hey there"; String ben = sam.toUpperCase( ); out.println( ben.compareTo(sam) );
32
String sam = "hey there"; String ben = sam.toUpperCase( ); out.println( sam.compareTo(ben) );
HEY THERE
String sam = "hey there"; sam = sam.toUpperCase( ); out.println( sam );
hey there
String sam = "hey there"; sam.toUpperCase( ); out.println( sam );
aplus
What is the output?
aplus compsci
What is the output?
aplus fun
What is the output?
compsci
What is the output?
compsci done
What is the output?
done
What is the output?
speed done
What is the output?
