What are the results of the following expressions? Verify your results via eclipse (using System.out.print()). Submission • Just answers. a. s1 == s2 b. s2 == s3 c. s1.equals(s2) d. s1.equals(s3) e. s1.compareTo(s2) f. s2.compareTo(s3) g. s2.compareTo(s2) h. s1.charAt(0) i. s1.indexOf('j') j. s1.indexOf("to") k. s1.lastIndexOf('a') l. s1.lastIndexOf("o", 15) m. s1.length() n. s1.substring(5) o. s1.substring(5, 11) p. s1.startsWith("Wel") q. s1.endsWith("Java") r. s1.toLowerCase() s. s1.toUpperCase() t. s1.concat(s2) u. s1.contains(s2) v. "\t Wel \t".trim()
Suppose that s1, s2, and s3 are four strings, given as follows: (5 points)
String s1 = "Welcome to Java";
String s2 = "
String s3 = "Welcome to Java";
What are the results of the following expressions? Verify your results via eclipse (using System.out.print()).
Submission
• Just answers.
a. s1 == s2
b. s2 == s3
c. s1.equals(s2)
d. s1.equals(s3)
e. s1.compareTo(s2)
f. s2.compareTo(s3)
g. s2.compareTo(s2)
h. s1.charAt(0)
i. s1.indexOf('j')
j. s1.indexOf("to")
k. s1.lastIndexOf('a')
l. s1.lastIndexOf("o", 15)
m. s1.length()
n. s1.substring(5)
o. s1.substring(5, 11)
p. s1.startsWith("Wel")
q. s1.endsWith("Java")
r. s1.toLowerCase()
s. s1.toUpperCase()
t. s1.concat(s2)
u. s1.contains(s2)
v. "\t Wel \t".trim()
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images