Question: in JAVA: My goal is for this code to find out if there are specific words in that string that is also in the array.
in JAVA:
My goal is for this code to find out if there are specific words in that string that is also in the array. If whats in the array is in the string, then it needs to be removed from the string.
Example:
Array[] = {"the", "an", "they", "he"};
Input: the cat is not a he.
Returns: cat is not a
Code should work for any similar input. DO not use (.contains, .replace, .remove or any other regular expressions).
If I have a comment please be able to respond.
My code so far:
import java.util.Scanner;
public static void main(String[] args)
String str = "";
String[] s1; String strTwo = ""; String[] words = {"the", "an", "they", "he"};
for (int i = 0; i < words.length; ++i) { s1 = str.split(words[i]); if (!str.equals(s1)) strTwo += str; }
System.out.println(strTwo);
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
