I have a listview that I am trying to populate by changing the text of the row xml to the file paths in the folder (so I can later perform operations on the files. I am getting a crash upon starting the activity. My code: FileView.java activity_file_view.xml row.xml I am getting this error: Appears to be a null object reference,
Tag: arraylist
Acces an ArrayList on a different method (same class)
im trying to acces the ArrayList “Lista” (with the modifications it had in the “Guardar” method) in the “verJugadores” method, is this possible? When I print the …
Sort List of Strings arrays in Java
I’m trying to make a program that consists of an array of Strings . now I need to sort them in order ‘PJ’, ‘GHS’, ‘FJ’, ‘PAS’ and date. input : output: //Always ‘PJ’, ‘GHS’, ‘FJ’ then ‘PAS’ Answer You should consider using custom java classes instead of String Array. Find below an example to do it .
Convert generic arraylist to non-generic using Java 8 Stream
I have some old code I’m trying to streamline: I want to use the Java Stream API to simplify this. Here is my attempt: My understanding is that it would iterate through arr, typecast every object m to an int, and then collect it into a List. But my compiler says that the right-hand-side of the second line returns and
Load an ArrayList with nested ArrayLists from a file using Java
I have an arraylist like ArrayList<ArrayList<String>>. I have saved my main ArrayList in a text file by using the following code. Now, I want to load the saved data from the file to the same ArrayList ar2 in every new run. I tried several methods but the nested arraylists are loaded as Strings. How can I overcome from this issue?
Finding the longest run of duplicate numbers in an ArrayList? (Beginner java)
This is my first time using stack overflow, so I’m so sorry if this is formatted incorrectly in any way. For a comp sci project, I have to do some different things to a 40-item Array List of random numbers. The task I’m struggling with is this: Count the longest run of the same number. A run continues only when
How is the ArrayList add(Type value) method O(1) amortized time complexity?
Most implementations of the ArrayList use an array internally and when the size is already exhausted upon adding an element to the list, it resizes or “grows” by essentially doing the following: caching a new array with a new batch of freshly allocated memory. copying all the elements of the internal array into the new array. setting the internal array
How to search in arrayList then change?
So i’m making a supermarket program that allows to add products and sell them, so far i have this: I´d like to know how to search in Product list by name and then change the stock(subtract-n) to sell n of that product. Answer You can use Stream API to find out the product by name. Filter the list by checking
I need an algorithmic help to convert an input Array object to ArrayList<List> object? [closed]
I need an algorithmic help to convert an input array in Java having this content : {5,6,3,2,4,7} To this format : [[2, 3], [3, 4], [4, 5], [5, 6], [6, 7]].
Cannot invoke ” ” because array is null
I need to add information about 2 actors such as their name, address and age and have done so without arrays easily but it’s necessary, I keep getting the error “Cannot invoke “TestActor.setName(String)” because “actors[0]” is null at TestMain.main(TestMain.java:5)” This is just a test main I’m using to test it ”’ And this is the actor class I’m using that