Showing posts with label string funtion. Show all posts
Showing posts with label string funtion. Show all posts

Saturday, 15 June 2013

use of java string funtion lowercase OR use of toLowercase()

/*change case to lower case*/
import java.io.*;

public class lowercase
{
    public static void main(String []args)
    {
        String str,str_2;
        try
        {
            DataInputStream cin=new DataInputStream(System.in);
            System.out.println("Enter any String ");
            str=cin.readLine();
            System.out.println("Your entered string is = "+str);
            str_2=str.toLowerCase();
            System.out.println(str_2);
        }
        catch(Exception e)
        {
            System.out.println(e);
        }
    }
}

java string funtion - upper case

import java.io.*;

public class uppercase
{
    public static void main(String []args)
    {
        String str,str_2;
        try
        {
            DataInputStream cin=new DataInputStream(System.in);
            System.out.println("Enter any String ");
            str=cin.readLine();
            System.out.println("Your entered string is = "+str);
            str_2=str.toUpperCase();
            System.out.println(str_2);
        }
        catch(Exception e)
        {
            System.out.println(e);
        }
    }
}

Friday, 14 June 2013

java program for indexOf() string funtion


import java.io.*;
class simple_index_of_type2
{
    public static void main(String args[])
    {
        String str;
        int pos;
        char s;
        try
        {
            DataInputStream cin=new DataInputStream(System.in);
            System.out.println("Enter any string ");
            str=cin.readLine();
            System.out.println("Enter character to search");
            s=Character.parseCharacter(cin.readLine());
            pos=str.indexOf(s);
            System.out.println("The entered string is = "+str);
            System.out.println("The possition of that character is = "+pos);
        }
        catch(Exception e)
        {
            System.out.println("wrong data");
        }
    }
}