how to multidimensional array Object to String in java

in #java6 years ago (edited)

2017101101710_0.jpg


public class test {
    public static void main(String[] args) {

        Object[][] obj = { { "1", "2", "3" }, { "1", "2", "3" }, { "1", "2", "3" } };

        System.out.println(Arrays.deepToString(obj));


        String[][] argument = Arrays.stream(obj).map(a -> Arrays.stream(a).map(Object::toString).toArray(String[]::new)).toArray(String[][]::new);

        for (int i = 0; i < argument.length; i++) {
            for (int k = 0; k < argument[i].length; k++) {
                System.out.println(argument[i][k]);
            }
        }
    }
}

Sort:  

Buat apa itu?

Posted using Partiko Android

ia adalah pasangan kod bahasa java.

Congratulations @carlton.soul! You have received a personal award!

1 Year on Steemit
Click on the badge to view your Board of Honor.

Do not miss the last post from @steemitboard:

SteemFest3 and SteemitBoard - Meet the Steemians Contest

Support SteemitBoard's project! Vote for its witness and get one more award!