package javaapplication1;
public class StringMethods {
public static void main(String ar[])
{
String str ="My name is abhishek awasthi";
System.out.println("The length of string is "+str.length());
System.out.println("The position of a in string is "+str.indexOf('a'));
System.out.println("The position of a in string from 5th location is "+str.indexOf('a',5));
System.out.println("The character at 5th location in string is "+str.charAt(5));
System.out.println("The substring from 3rd location till end in string is =>"+str.substring(3));
System.out.println("The substring from 5th location to 20th location in string is =>"+str.substring(5,20));
}
}
Output
0 comments:
Post a Comment