Comparing 2 dimensional Array to 1 dimensional Array in java -
There are elements array of array 1, so there are four element-arrays in array 1.
The second array is a one dimensional array.
My job is that every string of an element-array exists in array 2 or not. If present, the value should be printed.
string [] [] arr1 = {{"a", "b", "c", "d"}, {"a", "d", "f"} {"d", "a", "b"}, {"a", "b", "c", "d"}}; String [] arr2 = {"a", "b", "d", "f"}; should be output:
adfdab how can I process these arrays for the required output ?
{"A", "D", "F"}, {"D", "A", "B"}, {"A", "A", "C", "D"}, {"A" , "B", "c", "d"}}; String [] arr2 = {"a", "b", "d", "f"}; (String [] letters: arr1) {boolean contains all = true; For (string letters: letters) {boolean match = wrong; (For string: arr2) {if (letter.equals (s)) match = true; } If (! Match) {contains all = false; break; }} If (included in all) {System.out.println (Arrays.toString (letters)); }} is out:
[a, d, f] [d, a, b]
Comments
Post a Comment