28 Nov 2012

Array List Of Arrays Of Float in Java

Array List Of Arrays Of Float in Java

  • Jeder kann sowas einmal brauchen!
 package javaapplication4;
 import java.util.ArrayList;

 /**
 * @author chrissie
 */
 public class JavaApplication4 {
	 public static void main(String[] args) {

		 //
		 // Array List Of Arrays Of Float. Yeeha!
		 float x[] = {300.0f, 115.0f};

		 ArrayList<float[]> listX = new ArrayList<float[]>();

		 listX.add(x.clone()); 		// mind the clone!
		 listX.add(new float[]{400.f, 500.f});

		 System.out.println("x0->" + listX.get(0)[0]);
		 System.out.println("x1->" + listX.get(1)[0]);

		 //
		 // Array List of Array List of Arrays of Float. Yeeha!
		 ArrayList<ArrayList> bigListX = new ArrayList<ArrayList>();
		 bigListX.add(listX);

		 System.out.println("Java! " + ((float[]) bigListX.get(0).get(0))[0]);
	 }
 }