To find substring inside a string
import javax.swing.JOptionPane;
public class Substring_in_string
{
{
public static void main(String[] args)
{
String sData1=JOptionPane.showInputDialog("enter a string data");
String sData2=JOptionPane.showInputDialog("enter a sub string data");
if (sData1.contains(sData2) == true)
{
System.out.print("The substring exits ");
}
else
{
System.out.print("The substringdoes not exits ");
}
}
{
String sData1=JOptionPane.showInputDialog("enter a string data");
String sData2=JOptionPane.showInputDialog("enter a sub string data");
if (sData1.contains(sData2) == true)
{
System.out.print("The substring exits ");
}
else
{
System.out.print("The substringdoes not exits ");
}
}
}
No comments:
Post a Comment