Code:
class A
{
public static void main( String args[] )
{
String str = new String(" Government ");
String str1 = new String(" Computer ");
System.out.println(" Char At= " + str.charAt(4) );
System.out.println(" Compare To= " + str.compareTo(str1) );
System.out.println(" Equals= " + str.equals(str1) );
System.out.println(" Equals Ignore Case= " + str.equalsIgnoreCase(str1) );
System.out.println(" Length= " + str.length() );
System.out.println(" Replace= " + str.replace("e","a") );
System.out.println(" Start With= " + str.startsWith(str1) );
System.out.println(" End With= " + str.endsWith(str1) );
System.out.println(" Index Of= " + str.indexOf(5) );
System.out.println(" Sub String= " + str.substring(6) );
System.out.println(" LastIndexOf= " + str.lastIndexOf(5) );
}
}
class A
{
public static void main( String args[] )
{
String str = new String(" Government ");
String str1 = new String(" Computer ");
System.out.println(" Char At= " + str.charAt(4) );
System.out.println(" Compare To= " + str.compareTo(str1) );
System.out.println(" Equals= " + str.equals(str1) );
System.out.println(" Equals Ignore Case= " + str.equalsIgnoreCase(str1) );
System.out.println(" Length= " + str.length() );
System.out.println(" Replace= " + str.replace("e","a") );
System.out.println(" Start With= " + str.startsWith(str1) );
System.out.println(" End With= " + str.endsWith(str1) );
System.out.println(" Index Of= " + str.indexOf(5) );
System.out.println(" Sub String= " + str.substring(6) );
System.out.println(" LastIndexOf= " + str.lastIndexOf(5) );
}
}
Output: