list of arrays java

Solutions on MaxInterview for list of arrays java by the best coders in the world

showing results for - "list of arrays java"
Anaelle
27 Nov 2017
1List<int[]> A = new List<int[]>();
2
Zayne
12 Jun 2019
1ArrayList: part of Collections        
2does not support primitives, only support none primitives
3size is dynamic, automatically adjusted
4has index numbers
5ArrayList <DataType>  listName = new ArrayList <DataType> ();
6methods:
7add(): adds Objects to the arraylist
8get(index): gets the object at the given index, returns the object as it is
9size(): returns the length (size) of the arraylist as an int
10add(Object): adds objects to the arraylist
11add(index, Object): adds the object at the given index
12set(index, Object):  replacing the original object at given index with the new given object
13remove(int index): object at the given index will be removed. ONLY one
14 remove(Object): given object will be removed, returns boolean. ONLY one
15 clear(): remove everything from arraylist, size will be 0
16indexOf(Object): returns the index number of the object, int
17contains(Object): returns boolean 
18equals(ArrayListName): compares two arrayList 
19isEmpty(): returns boolean, depeding on the size
20
21Data Structures:
22		1. Array  ==>    Arrays (java.util)
23		2. Collection ==> Collections (java.util), does not support primitive
24		3. Maps  ==> does not support primitive
25 
26Methods:
27Bulk Operations:
28containsAll(CollectionType): verifies if all objects in CollectionType are contained in the list or not, returns boolean
29 
30addAll(CollectionType): adds multiple objects, adds all the objects from given collection type
31 
32removeAll(CollectionType): removes multiple objetcs, removes all the matching objects
33 
34retainAll(CollectionType): removes all the unmatching objects
35					{1,2,3,4,5,6,7,1,2,3,4}
36					removeAll(1,2,3,4) ==> {5,6,7}
37					retainAll(1,2,3,4) ==> {1,2,3,4,1,2,3,4 }
38 
39             Arrays.asList(object1, object2 ..): returns the collection type (List)
40 
41 ArrayList<Integer> numList = new ArrayList<>(CollectionType);
42 
43 sorting arrayList:
44	Collections.sort(ArrayListName); ==> Ascending order
45 
46	Collections: presented in "java.util" package
47		import PakageName.Classname;
48		import java.util.Collections;
49 
50  
51Collections Class:
52sort(CollectionType): sorting any given collectionType
53 
54frequency(CollectionType, Object): returns the frequency of the given object from the given collectionType
55 
56max(CollectionType): return the max object from collectiontype
57 
58min(CollectionType): return the min object from collectiontype
59 
60swap(CollectionType, index1, index2): swaps the elemnts at the given indexs from the CollectionType
61				list: {1,2,3,4,5}
62				Collections.swap(list, 1, 2); ==> {1,3,2,4,5}
63 
64replaceAll(CollectionType, oldValue, newValue):
65				list: {1,1,1,2,3,4,5}
66				Collections.replaceAll(list, 1, 10); ==>{10,10,10,2,3,4,5}
67
68Predicate:  can be applied to any collection-Type
69		number % 2 != 0
70 
71		Predicate<Ineteger>  oddNumber =  p -> p %2 != 0;
72 
73ArrayLisst method:
74remove If(Predicate): removes everything that's matching with the expression of predicate
75
Carla
25 May 2017
1List<Object[]> list = new ArrayList<>();
2list.add(new String[5]);
3list.add(new Integer[5]);
4Object[] objects = list.get(0);
5