Questions tagged [arraylist]

A simple collection data type found in some languages / platforms (such as in Java or .NET). The array list implements a list using an array, benefiting from both the DSs strengths.

0
votes
1answer
44 views

How do i multiple sort an array per column for all lines ? (JavaScript)

I have created a var rows to generate a csv. I would like to sort the content according 2 columns : DATE and TIME. DATE;TIME;ID;FACE;TOTAL;VAL1;VAL2; 07/05/2019;14:11:07;3234;0.00000038;2.00;-0....
0
votes
0answers
14 views

I am getting the error “Incompatible types” but they shouldn't be incompatible (Java) [duplicate]

In my main class I initialize some Filters and add them to the ArrayList healthyFoodlist. I then initialize the healthyFood Filter using this ArrayList. public static void main(String[] args) { ...
2
votes
1answer
20 views

How to set CardViews from ArrayList in ListView

So I'm working with my android app that takes data from firebase, basically a list of cars that I save into an ArrayList of a specific class. I want to show a list of CardView with one car object each,...
0
votes
1answer
35 views

How do I add multiple classes to a Generic ArrayList?

I'm doing an assignment where I can only add specific classes to a generic ArrayList, but the ArrayList does not seem to be adding the classes as intended. public class ComputerOrder<T extends ...
2
votes
1answer
33 views

Troubles with opening a large data set and instantiating the data in Java

I am attempting to read from a text file of GIS data in Java, instantiate each row of data, and then sort, search and insert data into it. I keep getting issues saying "at java.util.Scanner.next(...
0
votes
2answers
38 views

How do I find the index of the maximum value in an ArrayList<Integer>? [duplicate]

I'm writing a program to count how many times each unique word appears in a text file, then return the word that occurred the most times along with how many times it occurred. Because I don't know ...
0
votes
2answers
37 views

what is the fastest way to get the nth nextInt value?

I have to find the nth nextInt of each array element. The code below is really slow as the array elements are over 40k, and each array element is over a million. int[] numbers ={1000000,1004300,...
0
votes
2answers
19 views

How to populate Jtable with values from Arraylist (Null Pointer Exception in Jtables)

I am attempting to create a gui with two Jtables. One which outputs object Bike (if avaliable) and one which outputs object Rent. However Default Table Model keeps returning Null Point Exception. How ...
0
votes
1answer
24 views

Why only one arraylist in a class holds variables of all objects?

I have a problem mentioned in title. I will presenet every step for you to understand what I am trying to do. Firstly, in order to summarize my classes, I showed them below: Classes |___ Starter.java ...
0
votes
0answers
41 views

How do i split a string into a series of objects in an arraylist [on hold]

My code here is showing the scanner that extracts each line from the file and another scanner which is trying to split each line into objects called "Earthquake". private ArrayList<Earthquake> ...
-4
votes
0answers
29 views

i need to combine two arraylists of objects into third arraylist by merging few elements of both objects [on hold]

for (int i=0; i<=students.size(); i++) { if (students.get(i).candidateid == a2.get(i).candidateid) { students3.get(i).candidateid = students.get(i).candidateid ; students3.get(i).teacherid = ...
-1
votes
0answers
27 views

I have a problem with my login method, or with saving my objects [on hold]

So im writing a small program about ordering food. I have classes for the Shops , products and order, and I also have classes for Customers, RegisteredCustomers and VisitorCustomers. I've written the ...
1
vote
5answers
49 views

how to loop in a collection of ArrayList

i had a Hash Map, the key is a string and the value is array list, i want to check if Array List include a value then retrieve the key for the value. so i did this: Collection<ArrayList<String&...
-2
votes
3answers
44 views

Index Out Of Bounds Exception: Invalid index 0, size is 0 [duplicate]

So I have an android application and frequent forced close. Why on my logcat the following Method often causes errors? static void solveTSP(int[][] valuesMatrix) { shortestDistance = Integer....
0
votes
1answer
27 views

I am trying to get data from room database in arraylist but it shows only last record in android

I have room database in android. but when i am retrieving data from database and showing in expandable RecyclerView it shows only last records in my child list. there is one child ArrayList under the ...
0
votes
1answer
35 views

How to create a 3d array in java spring

This is my 1st project in java. I m trying to create a 3D array in Java but failed to do so till now. I tried multiple ways to create a 3d array. I declared a 3d String array and tried to add ...
1
vote
2answers
79 views

How can i change a value in an generic arraylist?

It's a code about a 'shopping cart' that can hold items of a class called 'item'. I had to complete the class 'item' and write another class 'discount' that can reduces the price of an item. import ...
0
votes
1answer
19 views

Setting data in Cloud Firestore with Kotlin

I have two fields in my firestore document: A number of comments which is a number and comments which is an array of objects. Now, I want to add a new comment to a comments array in the existing ...
0
votes
1answer
21 views

Why each key in a Map going to have all emails as a value reading from a file [duplicate]

i'm trying trying to read this file: Peter Gibbons:pgibbons@initech.com:pete@gmail.com Michael Bolton:mbolton@initech.com Samir Nagheenanajar:snagheenanajar@initech.com:samir@hotmail.com Milton ...
-1
votes
1answer
55 views

How to fix IndexOutOfBoundsException in Java Android App [duplicate]

Hi I'm trying to create an interactive Android quiz application in Java, and when I try to enter the quiz section I get an index out of bounds exception, does anyone know how to solve this? I have ...
0
votes
1answer
34 views

how to Post List<PointF> with retrofit multipart on android?

i want to make an android app which can send an image and PointF from canvas. i've already success to send an image with retorifit multipart. and my next goal is to send List. but i confused how to ...
0
votes
0answers
22 views

How to loop over names of Arraylists properly? [duplicate]

I have 10 Arraylists which I want to merge with other Arrays and then gets an output in the console. ArrayList<String> data0 = new ArrayList<>(); ArrayList<String> data1 = new ...
0
votes
2answers
52 views

Why add method concatenate element of arrList?

I have a string which is an boolean equation : data1+data2.data3 .. I would like to put my string text in an arrayList eq.getEquation() So, at the end I would like to have [data1,+,data2,.,data3]. ...
1
vote
1answer
99 views

How to create dynamic options for select box using array elements ? and use that option box value in another jsp page?

This Question is Linked with [this][1] question. I'm trying to create dynamically generated options for the select box using array elements. meanwhile, I want all the array elements to get displayed ...
0
votes
1answer
44 views

Re-shuffle the words to accommodate max words in a single line and create less number of lines using Java

Re-shuffle the words to accommodate max words in a single line of size 42 characters and create less number of lines using Java I have to create comma separated words and max size of a line is 42. ...
1
vote
2answers
23 views

Checking collision for each cube in ArrayList

I'm trying to check collision for each cube in arraylist, but the result is, that collision is working only for last cube in arraylist.. public class Cube { public int x, y; private boolean ...
-2
votes
0answers
35 views

How to send data from ArrayList and create recyclerView item, which will store this ArrayList data?

My app can be described as something like questioner creator. App user can manually make questions My app has an Activity(Activity1) with a few edit text fields. After filling editTexts, info from ...
1
vote
5answers
67 views

Get only those array values which are repeating N number of times in PHP

I am trying to get those values from array which are repeating N number of times in array. I know it sounds confusing. Let me give an example: I have an array as $filter: array[ 0 => "556878", ...
0
votes
0answers
16 views

Taking String input from user in for loop the iterator jumps to take second input from user [duplicate]

How string input is taken in arraylist.without giving the size of array list Arraylistdatabase obj=new Arraylistdatabase(); Scanner in=new Scanner (System.in); System.out.println("...
2
votes
2answers
41 views

Merge sort returns an ArrayList comprised of multiple duplicates of the first entry rather than a sorted ArrayList

Calling my Merge sort method on an ArrayList of data objects returns an ArrayList entirely comprised of the first entry in the original ArrayList (the original had 9k separate entries, while the '...
0
votes
1answer
31 views

Matchmaking system N vs N from list

I'm trying to make a matchmaking system... how it will work? Connected users will appear in the list and later they will randomly picked like: 3 vs 3 etc. depending on even number of players I've ...
0
votes
1answer
16 views

Is there a way to share a variable between separate arrays?

I want to know if it is possible to store variables in different arrays at the same time, for the purpose of saying "If in this list, do this, if also in this list, also do this." Basically, I want to ...
0
votes
1answer
35 views

ArrayList consisting of JButtons. But doesn't work as expected

I'm on a project right now and I'm trying out some new code to make my program more efficient. I was thinking of an ArrayList "dice" which will contain some buttons (that're supposed to be dice). If I ...
0
votes
1answer
41 views

Combining arraylists of different object types into one

I have some arraylists which contain objects (for a paint like program) based on a constructor in a class, and wish to put them all in the same arraylist rather so each item redraws in order. ive ...
0
votes
0answers
29 views

How to share multiple images with single caption in whatsapp?

I want to share image array via Whatsapp with text , but there is a text which always send with every image. I try many way but nothing works. try { Intent shareIntent = new Intent(android....
1
vote
0answers
25 views

Error from main arraylist GUI program. Not Sure how to fix it

I'm working on an assignment for my java class. We were given two main programs to test our programs on. The main GUI is getting an error i'm not sure how fix. I'm not allowed to make any changes to ...
-1
votes
2answers
34 views

Java Objects in Array List

i would like to run the update function automatically for every object i create. What do I have to change in my code, unfortunately it doesn't work How can I initialize an object in my ArrayList? :( ...
-1
votes
2answers
40 views

Finding element in an object by passing object as a parameter in method

public class ChairTester { public static void main(String[] args) { ArrayList<Chairs> chairs = new ArrayList<>(); chairs.add(new Chairs("Rolling", "red",1523, 200.00)); ...
-1
votes
0answers
10 views

Problem with arraylist connect to html5 table

i have a subpane made with bootrap with a table created with html and two symbol and description, i need to connect an array list to this table the arraylist is created with js it is possible to do ...
0
votes
1answer
44 views

Switch turns in a 2v2 game

I am building a turn based game with two sides. Each side can have up to two or more players. How do I alternate the turns in the game? When I have one player on each side, the solution is simple. ...
1
vote
3answers
44 views

Is there a Python Function for building a average Price which takes 2 arrays as arguments

first of all i'm absolutely new to Python and try to learn this by myself. I got the following exercise to practice and try to solve it with NumPy and Pandas. Share trades are recorded using 2 arrays....
0
votes
0answers
30 views

What type of key - value list would not impose a number to each element?

There's probably a better way to phrase my question. I have an object that one of its elements should be a list of key and value pairs. My problem is that when I save the object to firebase, the list ...
0
votes
1answer
41 views

Why the SharedPreference always get the unsorted arraylist in Android?

I am develop in Android , and try to writing ArrayList into SharedPreferencesString I use the following function to set and get data: fun setSharedPreferencesMutableList(context: Context, setName: ...
0
votes
3answers
56 views

How can I get name string in array list start with letter T and display name of teacher?

How can I get a list has the name of teachers starting with letter "T" in array list java. I want to display a list name of teachers. if the list of teachers is not exit, it will show "There are no ...
0
votes
2answers
44 views

Attempt to invoke virtual method 'boolean java.util.ArrayList.add on a null object reference

I'm creating an Android application. The problem is that when I press the button and pass the data to the new array, it goes to black and giving me this error: Caused by: java.lang....
1
vote
0answers
15 views

how can i increase the space between the circles drawn for creating the snake in the snake game i am creating?

I created a snake game on java and I managed to grow the snake whenever it eats food. But then the space of the ovals I draw are too close and I want to increase the space between them that should I ...
1
vote
1answer
45 views

Why after split line into an array, the code after for-loop doesn't work?

In this cycle, the string within an arraylist is divided, and each word is inserted into an array. I only need the date that is in second position to compare it with a date that I pass. If it is not ...
0
votes
2answers
34 views

ArrayList polymorphism in Java

I have a homework about Hospital Management System. I am mostly done but I have an issue about polymorphism. In my project I have 6 classes and 1 test class. These 6 classes are Doctor, OutPatient, ...
0
votes
0answers
19 views

Find maximum value from an ArrayList

I created an ArrayList function signature to find all the maximum household incomes from year 1984 to 2016. Now I wanted to find the maximum value from that ArrayList. I tried to use max() but it ...
2
votes
1answer
51 views

Sorting Array according to ArrayList using comparator

I'm trying to sort an Array (Object hits[]) that stores Objects and I need to be sorted with the exact order (asceding, descending) as in ArrayList which is already sorted. These two are not related ...

http://mssss.yulina-kosm.ru