A
A
Andrey Baranov2017-06-20 11:01:09
Java
Andrey Baranov, 2017-06-20 11:01:09

Converting string to two dimensional array?

There is a line like 1233\n2345\n3467\n5677.
This string needs to be converted to String [4][4].direct to the true path......how to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Arkadiy Parinov, 2017-06-20
@Young_khv

String str = "1233\n2345\n3467\n5677";
String[] arr= str.split("\n");
System.out.println(Arrays.toString(arr));

If you need character arrays, then for each element of the resulting array:
char[] charArray = str.toCharArray();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question