java - Iterating String Array by a specific value -


this question has answer here:

i'm iterating on arraylist string arrays inside.

["a","1"] ["a","2"] ["a","3"] ["b","1"] ["b","2"] ["b","3"] 

how can select ones "a" on first position? without iterating, , saving on new array...

for (string[] key : keys){   } 

using each example, want is, first iteration -> work string arrays "a", second iteration -> work string arrays "b".

try this:

    string[][] keys = {         {"a","1"},         {"a","2"},         {"a","3"},         {"b","1"},         {"b","2"},         {"b","3"},     };     string[][] result = stream.of(keys)         .filter(x -> x[0].equals("a"))         .toarray(string[][]::new);     system.out.println(arrays.deeptostring(result)); 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -