Tags "arraylist" Result

Java ArrayList of ArrayList

The following code outputs [[100, 200, 300], [100, 200, 300]]. However, what I expect is [[100, 200, 300], [100, 200]], Where am I wrong? public static void main(String[] args) { ArrayList<ArrayList<Integer>> outer = new ArrayList<ArrayList<Integer>>(); ArrayList<Integer> inner = new ArrayList<Inte

it1352 0 2019-05-08

Circular ArrayList (extending ArrayList)

So my program has a need of a type of circular ArrayList. Only circular thing about it has to be the get(int index) method, this is the original: /** * Returns the element at the specified position in this list. * * @param index index of the element to return * @return the element at the specified position in this list

it1352 0 2019-05-08


Hey, I have an arraylist which I have added a number of objects to (all the same type of object), I need to be able to check if the array already contain the object before adding it, I have tried something like... if Not myArray.contains(newObject) then myArray.Add(newObject) end if This will work with a string object but not a user defined objec

it1352 0 2019-06-25

Sorting Arraylist of Arraylist of Bean

I have an ArrayList of ArrayList of Bean and I need to sort this ArrayList according to the date variable in Bean. ArrayList<ArrayList<DriverLogDatePair>> driverLogList And DriverLogDatePair bean have a variable DateTime date, it also has a compareTo method. public int compareTo(DriverLogDatePair o) { return date.compareTo(o.dat

it1352 0 2019-05-14

Subtracting one arrayList from another arrayList

I have two arrayLists and I am trying to "subtract" one arrayList from another. For example, if I have one arrayList [1,2,3] and I am trying to subtract [0, 2, 4] the resulting arrayList should be [1,3]. List<Integer> a = new ArrayList<>(Arrays.asList(1, 2, 3)); List<Integer> b = Arrays.asList(0, 2, 4); subtract(a,b) // should r

it1352 0 2019-05-22

ArrayList looping

In Booking menu, i have main with 3 options:a,b and c. Option 'a' - selection of room types. 5 different room types to choose from. Option 'b'- selection of add-ons for each room.Each add-on can be selected for additional cost. Option 'c' - return from make booking page to main page My program needs to display 5 different types of room. At this po

it1352 0 2019-05-08

arraylist copy

Hi, I have the following code : Dim rNodeList As New ArrayList Dim rNodeListNew As New ArrayList For iCntr As Integer = 0 To tvRelations.Nodes.Count - 1 rNodeList.Add(tvRelations.Nodes(iCntr).Text) Next rNodeListNew = rNodeList rNodeList.RemoveAt(2) after I''ve filled rNodeList, it contains 8 elements. So does rNodeListNew But when I remove t

it1352 0 2019-06-25

ArrayList Issue

I have two values, small_red and small_blue: private EnemyInfo small_red = new EnemyInfo("Red Fighter", Core.jf.getToolkit().createImage(Core.class.getResource("/com/resources/ENEMY_01.png")), 10, 100, new Location(0, 0), false, 0); private EnemyInfo small_blue = new EnemyInfo("Blue Fighter", Core.jf.getToolkit().createImage(Core.class.getResource

it1352 1 2019-05-08

ArrayList problem.

If I use: ArrayList TimeScale = new ArrayList(); TimeScale.Capacity = 1000; TimeScale[20]="test 1" The last line trow me an error: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index Is there anything I don''t get here? Solution ArrayList objects are not arrays - it is (essentia

it1352 1 2019-06-25

ArrayList filter

How can you filter out something from a Java ArrayList like if you have: How are you How you doing Joe Mike And the filter is "How" it will remove Joe and Mike. Solution Probably the best way is to use Guava List<String> list = new ArrayList<String>(); list.add("How are you"); list.add("How you doing"); list.add("Joe"); list.add("

it1352 0 2019-05-08