Go to http://download.oracle.com/javase/8/docs/api/ Use the API for the String c
ID: 3741717 • Letter: G
Question
Go to http://download.oracle.com/javase/8/docs/api/
Use the API for the String class (java.lang.String) to answer the following questions. Assume that string1 and string2 are variables declared as type String. Also assume that num is an int variable. Write a complete Java statement as an answer for each question:
1- How can you create a new string from the 1st character to the 9th character of a string?
2- How can you create a new string from the 3rd character to the 7th character of a string?
3- How can you create a new string from the 5th character to the end of a string?
4- How can you join two strings together into a new string?
Explanation / Answer
1. string1.substring(0, 9); 2. string1.substring(2, 7); 3. string1.substring(4); 4. string1.concat(string2);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.