All Questions
3,693 questions
3
votes
2
answers
159
views
How to retrieve individual arrays from arrays of strings stored inside an ArrayList?
I'm working on an assignment where I need to take "books" from the user(a title, an author, and ISBN number, all strings), and store these books somehow, and then do various things to these ...
0
votes
0
answers
43
views
Drools - Pulling an ArrayList<String> from a HashMap<String, Object> in drools
For the life of me I cannot pull a simple String ArrayList from my generic hashmap: HashMap<String, Object>
I have been able to pull much more complicated structures such as List of objects ...
1
vote
4
answers
138
views
Accessing an array variable by "concatenating" root variable name + int [duplicate]
A total Java rookie here, I'm wondering if there's any way I could iterate over several arrays like:
myArray1
myArray2
myArray3
by doing some form of "concatenation" to invoke these arrays ...
-2
votes
6
answers
137
views
How do I check if the next element in ArrayList is empty or exists?
I have a 2D ArrayList for which I want to print out the names with commas if they're in the same row except for the last one. To do this I would need to check if the element before the one I am ...
-1
votes
1
answer
166
views
Performance of ArrayList<Integer> versus int[]
I have a million ints that I want to store in a data structure. I wanted to know whether the int array (int[]) is any more efficient than an ArrayList. Are there any performance gains to using int[] ...
1
vote
3
answers
247
views
Which List implementation does Kotlin use when calling listOf()
As known, in Java List is not a class, but an interface, so you can't get an instance of a List, you have to specify the implementation, like ArrayList, LinkedList, etc. So here is the question: which ...
-2
votes
3
answers
130
views
How to define and implement a fixed size "List" in Java? [duplicate]
I want to create an fixed size list in java, according to my searchings & readings from the internet i couldn't find that feature in java, However i want to create a fixed size list with 100 ...
-1
votes
1
answer
43
views
How should an ArrayList or similar structure be modified when elements regularly affect eachother every update of the container?
I am currently trying to create an entity based system for a game in Java with a handler class for updating and solving interaction between entities of different subclasses. They can damage each other ...
1
vote
3
answers
101
views
Can an object belong to both an array and arraylist simultaneously in Java?
I am struggling to write a code sample where an object can belong to an array and arraylist simultaneously and where modifying in arraylist or the array changes the object? See example where I was ...
1
vote
2
answers
84
views
Finding the count of index in array of
How to find whether an array of string has only one index? I am trying with below piece of code but it is throwing index out of bound exception while the string contain only one letter.
class Test {
...
0
votes
2
answers
43
views
Instantiating a 2d List that stores ArrayList with integer lists in Java
import java.util.HashSet;
import java.util.ArrayList;
class Solution {
public int longestIncreasingPath(int[][] matrix) {
List<ArrayList<Integer>>[][] dp = new List[matrix....
0
votes
4
answers
637
views
Unable to convert ArrayList to array in Java using toArray() method [duplicate]
I am tring to print N to 1 using recursion. But while doing so I am getting the following errors what should I change in the code to convert the ArrayList to array successfully
Here is the Code-->
...
0
votes
1
answer
65
views
Confusion about removing duplicates in java
I'd like some clarification on what the size-- specifically does for this, because the code did not run as expected until I added that. I thought the for loop accounted for change in size with each ...
1
vote
1
answer
449
views
Explain to a beginner how ArrayList and array are used in this method
My question relates the one method in an exercise I am doing while learning Java. I understand what the program is supposed to do (one method to determine if a number is prime, and the other to store ...
4
votes
1
answer
140
views
Extremly bad perfomance of ArrayList<Int> for large number of elements compared with IntArray
I made 2 implementations of quick sort: sequential and parallel. The second one was written using ForkJoinPool using 4 threads (I added implementaton below)
The sort function worked with ArrayList:
...