private static int[][][] pieces = 
		{
			{
				{
					1, 1, 1, 1, 1, 1, 1, 1
				},{
					1, 1, 1, 1, 1, 1, 1, 1
				},{
					1, 1, 1, 1, 1, 1, 1, 1
				},{
					1, 1, 1, 1, 1, 1, 1, 1
				}
			},{
				{
					
				}
			},{
				{
					
				}
			},{
				{
					
				}
			}
		};//continues on for size pieces[7][4][8]
	
	public static void main(String [] args){
		for(int x = 0; x < pieces.length; x++){
			for(int y = 0; y < pieces[x].length; y++){
				int[] tmp = pieces[x][y];
				int[] xs = {tmp[0], tmp[1], tmp[2], tmp[3]};
				int[] ys = {tmp[4], tmp[5], tmp[6], tmp[7]};
				System.out.println("pieces["+x+"]["+y+"] = "+Arrays.toString(xs)+Arrays.toString(ys));
			}
		}
	}

Is there any possible way to condense this three dimensional array into a two dimensional, or better yet, one dimensional array? When I try to run this on my Android phone, Eclipse does not generate the class/tex files. I'll be honest, I have no idea why this error came up, because I have used three dimensional arrays before, but here it is:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (classFileParser.cpp:3470), pid=2772, tid=5832
#  Error: ShouldNotReachHere()
#
# JRE version: 7.0-b144
# Java VM: Java HotSpot(TM) Client VM (21.0-b14 mixed mode windows-x86 )
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.sun.com/bugreport/crash.jsp
#

---------------  T H R E A D  ---------------

Current thread (0x0151a000):  JavaThread "Unknown thread" [_thread_in_vm, id=5832, stack(0x01290000,0x012e0000)]

Stack: [0x01290000,0x012e0000],  sp=0x012df270,  free space=316k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [jvm.dll+0x15d5f1]
V  [jvm.dll+0x15820b]
V  [jvm.dll+0x18b67]
V  [jvm.dll+0x1a3c8]
V  [jvm.dll+0x2a06f]
V  [jvm.dll+0x2b458]
V  [jvm.dll+0x2bb1b]
V  [jvm.dll+0x2bb6a]
V  [jvm.dll+0x2bcbd]
V  [jvm.dll+0x2bd9a]
V  [jvm.dll+0x2c017]
V  [jvm.dll+0x73391]
V  [jvm.dll+0x7374b]
V  [jvm.dll+0x11c24c]
V  [jvm.dll+0x13dd8a]
V  [jvm.dll+0xa1820]
C  [javaw.exe+0x1359]
C  [javaw.exe+0x1dc9]
C  [javaw.exe+0xa0cb]
C  [javaw.exe+0xa155]
C  [kernel32.dll+0x53c45]  BaseThreadInitThunk+0x12
C  [ntdll.dll+0x637f5]  RtlInitializeExceptionChain+0xef
C  [ntdll.dll+0x637c8]  RtlInitializeExceptionChain+0xc2


---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )

Other Threads:

=>0x0151a000 (exited) JavaThread "Unknown thread" [_thread_in_vm, id=5832, stack(0x01290000,0x012e0000)]

VM state:not at safepoint (not fully initialized)

VM Mutex/Monitor currently owned by a thread: None

Dynamic libraries:
0x01330000 - 0x0135f000 	C:\Program Files\Java\jre7\bin\javaw.exe
0x76ea0000 - 0x76fdc000 	C:\Windows\SYSTEM32\ntdll.dll
0x76fe0000 - 0x770b4000 	C:\Windows\system32\kernel32.dll
0x75210000 - 0x7525a000 	C:\Windows\system32\KERNELBASE.dll
0x758b0000 - 0x75950000 	C:\Windows\system32\ADVAPI32.dll
0x767f0000 - 0x7689c000 	C:\Windows\system32\msvcrt.dll
0x75890000 - 0x758a9000 	C:\Windows\SYSTEM32\sechost.dll
0x76730000 - 0x767d1000 	C:\Windows\system32\RPCRT4.dll
0x75350000 - 0x75419000 	C:\Windows\system32\USER32.dll
0x766e0000 - 0x7672e000 	C:\Windows\system32\GDI32.dll
0x770c0000 - 0x770ca000 	C:\Windows\system32\LPK.dll
0x76c50000 - 0x76ced000 	C:\Windows\system32\USP10.dll
0x74090000 - 0x7422e000 	C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.17514_none_41e6975e2bd6f2b2\COMCTL32.dll
0x752f0000 - 0x75347000 	C:\Windows\system32\SHLWAPI.dll
0x768b0000 - 0x768cf000 	C:\Windows\system32\IMM32.DLL
0x76930000 - 0x769fc000 	C:\Windows\system32\MSCTF.dll
0x699b0000 - 0x69a6e000 	C:\Program Files\Java\jre7\bin\msvcr100.dll
0x63e10000 - 0x64129000 	C:\Program Files\Java\jre7\bin\client\jvm.dll
0x71d10000 - 0x71d17000 	C:\Windows\system32\WSOCK32.dll
0x76a00000 - 0x76a35000 	C:\Windows\system32\WS2_32.dll
0x768a0000 - 0x768a6000 	C:\Windows\system32\NSI.dll
0x71bc0000 - 0x71bf2000 	C:\Windows\system32\WINMM.dll
0x73250000 - 0x7325c000 	C:\Program Files\Java\jre7\bin\verify.dll
0x73230000 - 0x73250000 	C:\Program Files\Java\jre7\bin\java.dll
0x767e0000 - 0x767e5000 	C:\Windows\system32\PSAPI.DLL
0x730c0000 - 0x730d3000 	C:\Program Files\Java\jre7\bin\zip.dll

VM Arguments:
jvm_args: -Dfile.encoding=Cp1252 -Xbootclasspath:C:\Program Files\Android\android-sdk\platforms\android-8\android.jar 
java_command: com.armanious.Redacted
Launcher Type: SUN_STANDARD

Environment Variables:
CLASSPATH=.;.;C:\PROGRA~1\Java\JMF21~1.1E\lib\sound.jar;C:\PROGRA~1\Java\JMF21~1.1E\lib\jmf.jar;C:\PROGRA~1\Java\JMF21~1.1E\lib
PATH=C:/Program Files/Java/jre7/bin/client;C:/Program Files/Java/jre7/bin;C:/Program Files/Java/jre7/lib/i386;C:\Program Files\Android\android-sdk\tools;C:\Program Files\Android\android-sdk\platform-tools;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\Java\jdk1.7.0\bin;C:\Program Files\MATLAB\R2010a\runtime\win32;C:\Program Files\MATLAB\R2010a\bin;C:\Program Files\QuickTime\QTSystem;C:\Program Files\MySQL\MySQL Server 5.1\bin;C:\Program Files\Python\lib;C:\Program Files\Python;C:\Program Files\Common Files\Teleca Shared;C:\Users\David\Documents\eclipse;
USERNAME=David
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 17 Model 3 Stepping 1, AuthenticAMD



---------------  S Y S T E M  ---------------

OS: Windows 7 Build 7601 Service Pack 1

CPU:total 2 (2 cores per cpu, 1 threads per core) family 17 model 3 stepping 1, cmov, cx8, fxsr, mmx, sse, sse2, sse3, mmxext, 3dnowpref

Memory: 4k page, physical 2881972k(959320k free), swap 5762188k(3649048k free)

vm_info: Java HotSpot(TM) Client VM (21.0-b14) for windows-x86 JRE (1.7.0-ea-b144), built on May 26 2011 13:20:51 by "java_re" with unknown MS VC++:1600

time: Fri Jul 01 00:45:00 2011
elapsed time: 0 seconds

Edited 5 Years Ago by Armanious: n/a

Is there any possible way to condense this three dimensional array into a two dimensional, or better yet, one dimensional array?

Yes, define a mapping from x,y,z to i
It might help if you took a piece of paper and wrote out a small 3 dim array with the x,y,z indexes for each element and then go back and assign it the i index of a single dim array. There should be some pattern here that you can use to write some loops to do the conversion.

for int x = 0 x < dimension1
for int y = 0 y < dimension2
for int z = 0 z < dimension3
newarray[z + (x * z) + (x * y * z)] = 3darray[x][y][z]
next everything

Should do the trick. I'm pretty tired writing this so you might not want to take my word for it.

This article has been dead for over six months. Start a new discussion instead.