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");
}
}
}
No comments:
Post a Comment