import java.io.*; import java.lang.*; import java.lang.reflect.Array; import java.util.*; public class SMA391_Project { public static void main (String [] args) throws java.lang.Exception{ Scanner in = new Scanner(System.in); System.out.println("Enter the Sentence"); String strOrig = in.nextLine(); //sentence String strOrig2=in.nextLine(); //word String [] splited = strOrig.split("\\b+"); System.out.println(Arrays.asList(splited).contains("strOrig2")); int intIndex = strOrig.indexOf("strOrig"); if(intIndex == -1){ System.out.println(strOrig2+" not found"); }else { System.out.println("Found "+strOrig2+" at index " + intIndex); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)