Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java list of arrays

import java.util.*;

public class ListofArrays {
	public static void main(String []args)
	{
		List<Integer[]> list;
		list = new ArrayList<Integer[]>();

		// Let us create 2 arrays of type Integer

		Integer [] arr1 = new Integer[5];
		Integer [] arr2 = new Integer[5];
		//arr1 stores numbers from 0 to 4
		//arr2 stores the numbers from 5 to 9
		for(int i=0;i<5;i++)
		{
			arr1[i] = i;
		}
		for(int i=0;i<5;i++)
		{
			arr2[i] = i+5;
		}
		//adding both arrays to list
		list.add(arr1);
		list.add(arr2);
		//print elements of the list
		for(int i=0;i<list.size();i++)
		{
			Integer [] arr = list.get(i);
			for(int j=0;j<arr.length;j++)
			{
				System.out.print(arr[j]+ " ");
			}
			System.out.println();
		}
	}
}
Comment

list of arrays java

List<int[]> A = new List<int[]>();
Comment

list of arrays

List<Object[]> list = new ArrayList<>();
list.add(new String[5]);
list.add(new Integer[5]);
Object[] objects = list.get(0);
Comment

PREVIOUS NEXT
Code Example
Java :: switch statement java 
Java :: what are method in java 
Java :: spring valid request body custom message 
Java :: java bigdecimal 
Java :: java lambda expressions 
Java :: Array List java can I add a pair of element 
Java :: write in file java 
Java :: exception in thread "main" java.lang.unsupportedclassversionerror: has been compiled by a more recent version of the java runtime (class file version 55.0), this version of the java runtime only recognizes class file versions up to 52.0 
Java :: lauch java batch 
Java :: how to initialize char in java 
Java :: java create arraylist with size 
Java :: write content to file java 
Java :: java get substring 
Java :: java asynchronous programming example 
Java :: android foreground services set auto cancel not working 
Java :: how to find the length of an array in java 
Java :: How to merge two sorted arrays into a single sorted aggregate one? 
Java :: javafx edit list 
Java :: maven skip make-assembly 
Java :: java mostrar resultados ventana grafica 
Java :: type variable java 
Java :: .jar window immediately closes on doubleclick 
Java :: how to remove scroll pane border 
Java :: Odd or even program in java using a mod operator 
Java :: hwo to create a list of 1 to n nums in java list 
Java :: java array object 
Java :: enable cors on apache tomcat 
Java :: switch en java 
Java :: why static variables cannot be serialized in java 
Java :: java string split underscore 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =