Check one array entry to each other entry in another array?
If possible please could i get a bit of guidance.
There are two (at least) problems with this code i've written.
The arguments get broken down and stored into array, no problems.
The problem is that in the if loop how can i get the array[n] to check in systematically against each entry in the arrayTest[g] argument?????
Edit, i have tried recoding this method three different ways, using a forEach loop, while loop and nested for loops. And i've tried splitting each string down to individual letters and comparing them one at a time as suggested in the English to text translator thread on this forum, but each time it comes back down to the If loop not functioning as it should, but it's got me well stumped.
Thanks in advance for any help given.
public static String testMethod(String input, String testInput)
int n = 0;
int m = 0;
int f = n+1;
String array = new String[input.length()];
String testArray = new String[testInput.length()];
StringBuilder result = new StringBuilder();
for(int p =0; p < array.length; p++) // take first argument and store in array
array[p] = input.substring(p,p+1);
for(int q = 0; q < testArray.length; q++) // take second argument and store in array
testArray[q] = testInput.substring(q,q+1);
for (int g = 0; g < testArray.length; g++) // compare first array entry with second array
// entry if they match. Add entry to string builder
if (array[n].equals(testArray[g])) // How to make this loop compare n to each value of
// g until it finds a match or reaches the end of
// the testArray????
else // If first and second arrays don't match check next
// array element to see if that matches.
g -= n;
n = 0; // As soon as this becomes n++; i get out of index issues
String returnResult = new String(result);