0
Does this code is right or need to do some changes? It basicly search the Given word by user in a String nd prnt index of word
{ Scanner input = new Scanner(System.in); String Sent="Anything is bttr xyz than nothing"; Serch(Sent,"xyz"); } public static void Serch(String sent,String word){ String n ; for (int i =0;i<sent.length();i++){ if (sent.charAt(i)!=' '){ n = sent.charAt(i)+""+sent.charAt(i+1)+""+sent.charAt(i+2); if ("xyz".equals(n)) { System.out.println("Index : "+i+" word is : "+n); n = n.replace(n," "); System.out.println(n); break; } } } }
5 Respuestas
+ 2
Where is your main method first of all?
+ 1
Abdul Wahab you don't need to post entire code in description. If it doesn't fit due to character limit , use playground, and attach link in description.
https://www.sololearn.com/post/75089/?ref=app
0
Avinesh i just copy the Main method body i just code only because there is word limit in Description which is 128 maximum words thts why i have to remove the main method header
0
Abdul Wahab the program outputs the result perfectly, what do you want now?
0
Avinesh thanks. I didn't knew about this. Cux i am new one here sorry