logo CodeStepByStep logo

marshallMathers

Language/Type: Java string

Given the following variable declarations:

// index       0123456789012345678901234
String s1   = "Snoop Dogg";
String s2   = "Marshall 'Eminem' Mathers";
String s3   = s2.substring(18);
String book = "Art & Science of Java";

Give the results of the following expressions. Make sure to indicate a value of the proper type (e.g. strings in " " quotes).

s1.length()
s2.length()
s1.indexOf("o")
s2.indexOf("x")
s1.substring(6, 9)
s2.substring(21)
book.substring(6, 12)
s3.toLowerCase()

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.