0

I'm trying to implement a 3D array in Java but I've a problem, my problem is that I don't know one of the lengths of 3D array size, it means that third length of my 3D is variable and it depends on the input size. In other words my 3D array called

int arcbits[64][1][length(input)];

first two sizes are fixed, it's always [64][1] and just the third length is variable.

length(input) is always positive integer greater zero. Input is like this form = {1,0,1,1}, so in this case for instance the arcbits size is:

int arcbits[64][1][4];

How do I implement that in Java? My problem is that there's a variable length which for instance in c++ or c we do dynamic allocation ...because we don't know the size of the array. So do I do 3D array in Java with implicitly variable size?!

I'm stuck on this about two days and I didn't succeed to implement 3D array in Java, this is the first time I counter this, any suggestion to help me out?

Community
  • 1
  • 1
TonyVany
  • 7
  • 4

2 Answers2

0
int[][][] arcbits = new int[64][1][length(input)];

See https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html

Unmitigated
  • 76,500
  • 11
  • 62
  • 80
0

see here: Sum in Java (built in method)'s Implementation?

I already declared 3d array in java, I guess you look on the same concept.