Consider the line of code String string1 new StringCoursera

Consider the line of code: String string1 = new String(\"Coursera\"); What linc(s) of code can you use to assign the char \'s\' to the variable letter? Answer:

Solution

char letter;
for(int i=0;i<string1.length();i++)
{
if(string1.charAt(i)==\'s\')
{
letter=string1.charAt(i);
}
}

 Consider the line of code: String string1 = new String(\

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site