publicclass JAVA_050
{
publicstaticvoid main(String[] args)
{
String Text="To be or not to be, that is the question; Whether 'this"
+"nobler in the mind to suffer the sling and arrows of "
+"outrageous fortune, or to take arms against a sea of "
+"troubles, and by opposing end them?";
System.out.println("Text paragraph is : \n" + Text + "\n");
int index=Text.indexOf('b');
if(index!=-1)
System.out.println("From start, first 'b' is present at the position : " + index);
else
System.out.println("'b' is not present in the above text.");
index=Text.indexOf('b',++index);
if(index!=-1)
System.out.println("From start, second 'b' is present at the position : " + index);
else
System.out.println("'b' is not present in the above text.");
index=Text.lastIndexOf('b');
if(index!=-1)
System.out.println("\nFrom end, first 'b' is present at the position : " + index);
else
System.out.println("'b' is not present in the above text.");
index=Text.lastIndexOf('b',--index);
if(index!=-1)
System.out.println("From end, second 'b' is present at the position : " + index);
else
System.out.println("'b' is not present in the above text.");
}
}