Initializing Multidimentional Arrays
Posted
by Eddy Freeman
on Stack Overflow
See other posts from Stack Overflow
or by Eddy Freeman
Published on 2010-04-20T05:39:43Z
Indexed on
2010/04/20
5:43 UTC
Read the original article
Hit count: 299
java
Hi Guy,
I have a 3-multidimentional array :
int[][][] env;
which i would like to initialize with data in a text file. The data in the text file looks like this:
{ { { 0, 1,-1},
{ 0, 2,-1},
{-1,-1,-2},
{ 0, 0, 0} },
{ { 0, 0,-1},
{ 0, 0,-1},
{-1,-1,-2},
{ 0, 0, 0} }
}
Actually the accolades can be removed and replaced with different characters if it is necessary. If there are any better way to format the values in the text file, then it is welcomed.
I am looking for the best way to initialize the array in the java program with the values from the text file.
All your help is appreciated.
Thanks.
© Stack Overflow or respective owner