Skip to content
Advertisement

Tag: arraylist

How to write a JUnit test case for ArrayStack methods

I am implementing an ArrayStack and we have to create a tester for it with JUnit and I wasn’t sure what to add to check if these two methods are working. The method addAll appends all values from the given list into the other list. Equals checks if two ArrayStacks are equal. I think I would have to create another

Saving an ArrayList<ArrayList> to File

I am able to save an ArrayList to a file without any problems, but when I try to write and read an ArrayList<ArrayList<Integer>> to file it nulls out the values. I cannot find an example of this format working, or any subject matter as to why it wouldn’t work. Does anyone have any insight into why this might happen, or

Drawing raffle numbers out of list that can have duplicates in Java

I was trying to learn programming by writing code with friends, we are all new though and are stuck with this raffle program. Players can earn multiple raffle tickets. The raffle tickets are written down in a new row in an ArrayList when they are earned. It looks like this: “PlayerA PlayerB PlayerB PlayerC PlayerD PlayerE PlayerF” Now we want

Android NullPointer Attempt to invoke virtual method ‘boolean java.util.ArrayList.add(java.lang.Object)’ on a null object reference

I’m getting this error: java.lang.NullPointerException: Attempt to invoke virtual method ‘boolean java.util.ArrayList.add(java.lang.Object)’ on a null object reference and just to make it clear is that I know others with the same issue have asked the same question and I have read the solutions which are usually that you have to instantiate your ArrayList which however I am obviously doing but

Advertisement