Create a Project named Chap7. Follow the instructions for PE 7. Create your code
ID: 3817180 • Letter: C
Question
Create a Project named Chap7. Follow the instructions for PE 7. Create your code. Zip the folder Chap7 and upload. For reference see pages 363-364 in the text book. Make sure your code has the following comments at the beginning of your program with the appropriate information://Filename//Written by//Written on index of ('v') is 10 index of ('x') is: -1 char At (16) is: o endsWith ("bus") is true endsWith ("car") is: false replace ('c', 'C') is: You Can never Cross the ocean until you have the Courage to lose sight of the shore. -Christopher ColumbusExplanation / Answer
class Chap7
{
public static void main(String args[])
{
//Reference String taken
String s="You can never cross the ocean until you have the courage to lose sight of the shore. - Christopher Columbus";
//checked index for given char
System.out.println("index.of('v') is: "+s.indexOf('v'));
System.out.println("index.of('x') is: "+s.indexOf('x'));
//checked character at given location
System.out.println("char.At(16) is: "+s.charAt(16));
//substring checked at the end position
System.out.println("endsWith(bus) is: "+s.endsWith("bus"));
System.out.println("endsWith(car) is: "+s.endsWith("car"));
//lowercase character replaced with uppercase character
System.out.println("replace('c','C') is: "+s.replace('c','C'));
}
}