Get expert insights and community-driven knowledge on IDNLearn.com. Our experts are available to provide accurate, comprehensive answers to help you make informed decisions about any topic or issue you encounter.

Assume myString and yourString are variables of type String already declared and initialized. Write ONE line of code that sets yourString to the first character and the last character of myString added to myString variable.

Sagot :

Answer:

line of code :

newString=myString+myString.charAt(0)+myString.charAt(myString.length()-1);

Explanation:

In Java, the + is used for concatenation

method

charAt() will return the character from the given index from string

myString.charAt(0) will return E

myString.charAt(myString.length()-1)