I am trying to save all common words from arr1 and arr2 and then store to arr3.
String[] arr1 = {"pEace", "happiness", "Gives", "So", "aaa"}; String[] arr2 = {"pEace", "HappiNess", "joy", "give", "AAA", "enjoy", "learN"}; int k = 0; String[] arr3 = new String[0]; for (int i = 0; i < arr1.length; i++) { for (int j = 0; j < arr2.length; j++) { if (arr1[i].equalsIgnoreCase(arr2[j])) { System.out.println(arr1[i]); arr3[k] = arr1[i]; k++; } } } System.out.println(Arrays.toString(arr3));
https://stackoverflow.com/questions/66914316/how-do-i-save-common-words-from-two-arrays-into-a-third-array April 02, 2021 at 12:08PM
没有评论:
发表评论