CODING:
import javax.swing.JOptionPane;
class indexof
{
public static void main(String[] args)
{
String s="Programming Example Of JAVA";
System.out.println(s);
System.out.println("E is " + s.indexOf('E') + "th Position.");
String s1=JOptionPane.showInputDialog(null,"Choose any word in Programming Example Of JAVA");
System.out.println(s1 + " is " + s.indexOf(s1) + "th Position.");
System.out.println("Search E after 10th index at position :" + s.indexOf('E', 10));
s1=JOptionPane.showInputDialog(null,"Choose any word in Examples Of JAVA.");
System.out.println("Search " + s1 + "after 10th index at position :" + " is " + s.indexOf(s1,10) + "th Position.");
}
}
Comments
Post a Comment