/* 5 string operations */
import java.io.*;
class Main
{
public static void main(String args[]) throws Exception
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a string: ");
String st=br.readLine();
System.out.println();
System.out.println("String operation 1");
System.out.println("------------------");
System.out.println("Lower case of given string: "+st.toLowerCase());
System.out.println();
System.out.println("String operation 2");
System.out.println("------------------");
System.out.println("Upper case of given string: "+st.toUpperCase());
System.out.println();
System.out.println("String operation 3");
System.out.println("------------------");
System.out.println("Length of given string: "+st.length());
System.out.println();
System.out.println("String operation 4");
System.out.println("------------------");
System.out.println("Character at first position of given string: "+st.charAt(0));
System.out.println();
System.out.println("String operation 5");
System.out.println("------------------");
char ch[]=st.toCharArray();
System.out.println("After converting the given stringinto character array: ");
for(int i=0;i<st.length();i++)
System.out.print("\t"+ch[i]);
System.out.println();
}
}
No comments:
Post a Comment