Posted by : Unknown Sunday 28 June 2015


class StringDemo
{
public static void main (String args[])
{
String str = "I am vijay";
System.out.println("The string is: " + str);
System.out.println("The string in upper case: " + str.toUpperCase());
System.out.println("Length of this string: " + str.length());
System.out.println("The character at position 5: "+ str.charAt(5));
System.out.println("The index of the character y: " + str.indexOf('y'));
System.out.println("The substring from 2 to 10: " + str.substring(2, 10));
System.out.println("The index of the beginning of the substring vijay: " + str.indexOf("vijay"));
}
}

Output:

The string is: I am vijay
The string in upper case: I AM VIJAY
Length of this string: 10
The character at position 5: v
The index of the character y: 9
The substring from 2 to 10: am vijay
The index of the beginning of the substring vijay: 5

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Welcome to My Blog

Translate

Popular Post

Total Pageviews

Blog Archive

- Copyright © Learning Java Program - Powered by Blogger -