As of May 31, 2023, we have updated our Code of Conduct.

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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
11 views

Accessing collection in an agent in Anylogic

I am new to any logic. Can anyone give me pointers over my issue ? The problem I am facing is that I have created a collection in an agent. I am sending a msg with arraylist as its Type from one agent ...
Zainab's user avatar
  • 3
-2 votes
0 answers
14 views

How to get original values from a class inside an Array list [duplicate]

I have created two classes. first one is IteratorDemo.java and another one is ArrayListDemo.java. then I called IteratorDemo class inside ArrayList class then I ran the program and the output is came ...
Haris's user avatar
  • 1
2 votes
1 answer
34 views

Cumulative sum on list

I am a beginner in python programming. I am trying to perform cumulative addition on values of a list. values=[1,2,3] for i in range(len(values)): print(sum(values[0:i])) Output is 0 1 3 Whereas ...
suganya thangappan's user avatar
0 votes
1 answer
17 views

Trying to Compute the differences in two different ArrayLists of Objects with Instance Fields of Type Integer[JAVA]

package pckg; import java.util.ArrayList; import java.util.HashMap; public class Tester { public static void main(String[] args) { ArrayList<TesterObj> my_first_objects = new ...
Dean Waters's user avatar
0 votes
1 answer
50 views

How to delete an object that is a reference type from an ArrayList?

I'm trying to figure out how to achieve deletion of an object inside an ArrayList when the object is a reference type. Consider the following code: $leftTable = Import-Csv -Delimiter ';' -Path "...
Philippe Hebert's user avatar
2 votes
1 answer
40 views

Delete a nested array or PSCustomObject from an ArrayList

I don't get why this is not working, but I would like to understand what is going on here? Suppose that I have an ArrayList that contains these nested values: [System.Collections.ArrayList]$al = @(@(0,...
Philippe Hebert's user avatar
0 votes
3 answers
58 views

How to find an index of the ArrayList from the starting index in Java?

I want to search for an index of the element in the ArrayList but I want to start searching from starting index different than 0. I tried like this: import java.util.*; public class Test{ public ...
Ser's user avatar
  • 13
-2 votes
1 answer
38 views

Why won't Binary search find an element in Java?

Why won't Binary Search find an element? I have one array with elements: BBBB, BBBB, CCCC. I want to find elements BBBB and BBBB. I want binary search to find two elements and it finds one. The output ...
Ser's user avatar
  • 13
0 votes
1 answer
25 views

How to make an Array of images getting by input field and display the Array image as slider

My problem is to make array of image by input field and display array images as slider in JavaScript anyone can solve it please answer me Please give code of JavaScript document.querySelector(&...
ayyan Mohsin's user avatar
0 votes
1 answer
28 views

Iter-selection data from a row-list and multiply each value with multiple csv files in order , Python

I have multiple csv files can be read in order using glob in pandas. Each file should multiply with a value from a list in order. Here is the code I wrote to read the whole csv file: #list file list = ...
Dima's user avatar
  • 1
0 votes
0 answers
18 views

Why HashMap is not showing entryset outside the if condition [duplicate]

What is wrong with this code. why i am not able to get the entryset outside of this if condition? public class test{ public static void main(String args[]) { ArrayList <String>recordList = ...
Shaheaz's user avatar
  • 11
-1 votes
0 answers
43 views

How do I implement Insertion Sort with an ArrayList in Java? [closed]

I recently was asked to make a function that can take any non-negative integer as an argument and return it with its digits in descending order. For example, an input of 42145 should output 54421. I ...
Emmett5170's user avatar
-4 votes
0 answers
25 views

I'm confused on array incrementation and decrementation in this code [closed]

I cannot understand why the array needs to be incremented in the first place if it needs to be decremented later. If there is a remainder left, only then the "if" loop is going to add ...
dot's user avatar
  • 1
0 votes
1 answer
25 views

Drools Project Build Fails using ArrayList Condition

I'm having trouble building a kjar with maven when any of the .drl files contain an ArrayList conditional. For example, here is a rule from the tutorial that is causing this issue. I tested this with ...
Otisburg's user avatar
0 votes
4 answers
71 views

ow to separate a string from Scanner and store each word in an ArrayList?

How to add string from Scanner to ArrayList in split way? First I tried this: Scanner sc = new Scanner(System.in); ArrayList<String> yourList = new ArrayList<>(); while (sc.hasNext()) { ...
Oleg Khandozhko's user avatar
0 votes
1 answer
33 views

I want to dynamically change class with respect to status

I am using react and using map function . I want to use conditionally change class when my payment status will change I use if else statement but its give that status is not define . <table ...
nishikant singh's user avatar
0 votes
2 answers
61 views

Is ArrayList<String> an extendable class or should it be replaced with ArrayList?

Is ArrayList<String> a class? If not, why does public static class StringArrayList extends ArrayList<String> work? To compare two strings in ArrayList<String> I had to override the ...
IvoryAlpaca's user avatar
-2 votes
0 answers
20 views

Why cant I instantiate types. " Games myGames = new Games();

I am trying to run my code but before doing so I need to instantiate the types through my code. I have 5 pages of code the first being DuelMain.java below ... import java.util.Scanner; public ...
G. Mckenzie Hudgens's user avatar
-1 votes
0 answers
39 views

Cannot make a static reference to the non-static type T error in Java generic arraylist [closed]

Die Aufgabe ist, eine generische Klasse zu schreiben, die eine Array Liste für jeden möglichen Datentyp erstellen kann. Wie kann ich T richtig referenzieren? Die Fehlermeldung bei ArrayGList iList = ...
Lukas's user avatar
  • 1
0 votes
1 answer
23 views

How to print table element in selenium?

I am trying to print table data element by using the code shown here; there is no error, but the result is not as expected - please help. import java.util.List; import org.openqa.selenium.By; import ...
Sanjay Mardi's user avatar
0 votes
1 answer
26 views

Exception in thread main java.lang.NullPointerException at Runner.takeInput(Runner.java:24) at Runner.main(Runner.java:55) [duplicate]

There was this problem named "Duplicate in the array" where we need to find a number which is occurring two times in an array where number of elements are N and all elements between 1 and N-...
UTKARSH JOSHI's user avatar
-2 votes
0 answers
54 views

PHP Array marge issue

arrray 1 = [ "id" => 46 "sequence" => "1" "subCategory" => [ [ "id" => 47 "sequence" =>...
Invitado Invitado's user avatar
0 votes
1 answer
42 views

Comparing elements in Java Arraylist [duplicate]

List<Integer> li= Arrays.asList(106,106,248,248,286,286,344,357,357); System.out.println(li.get(4) == li.get(5)); System.out.println(li.get(0) == li.get(1)); Why first one print false ...
user2740683's user avatar
0 votes
2 answers
42 views

How to add a new button to display when the array has more than 2 values?

I'm learning JS and I'm facing a problem, I've written my code below. var AddStock = document.createElement('button'); //Button for adding the ticker to the list var Ticker = document.createElement('...
Dennis's user avatar
  • 3
0 votes
0 answers
13 views

I can't get the input of the arraylist in java why? [duplicate]

I have one problem in List and LinkedHashSet in java // Java Program import java.util.*; public class always_edit_this { public static void main(String [] args) { Scanner sc = new ...
Jeevanandham 17's user avatar
0 votes
0 answers
22 views

Duplicate Web client calls with collect list in Spring Boot Web Flux

I am creating a reporting solution where I need to get data from other services in reactive manner using Spring boot WebClient. To save webclient calls in case of list, I used code to create a list ...
Kuldeep KV's user avatar
0 votes
3 answers
60 views

How do I prevent a numpy ndarray column from being converted to string when saving a Pandas DataFrame to csv?

I have an DataFrame which is including an "ID" column and "Vector"(which includes (1,500) sized arrays) column. I have to save the DF as csv. When I convert the saved csv to DF ...
Fatih G.'s user avatar
1 vote
2 answers
61 views

How can I improve efficiency in my C code for calculating the average of words per line?

I'm trying to do the average of words per line in an array. I was trying to do a program that reads words until EOF is entered (by ctrl + z), then it displays the amount of words that were entered (...
N4ti's user avatar
  • 11
0 votes
1 answer
34 views

how to check whether it contains some string from the inclusive list but not from the exclusive list in C#

How to check whether the string is present in the urgent list. if an urgent word contains in the non-urgent list it should be false if the urgent word is present in the urgent list and the non-urgent ...
dotnetdev1's user avatar
-1 votes
0 answers
50 views

Java list.remove(obj) does not remove element from same list in for loop

I have a list of ids: List idList. Basically I have to loop through this list and pass the operated id to the executor along with the idList itself. After each execution, operated id should be removed ...
Orkhan19's user avatar
0 votes
1 answer
26 views

Can't add items to ArrayList that store inside class

I should to use addList, setList and getList when need in fragment. But I can't add item to list. It is 0 size in always. Why can not do this? RequestFragment.kt ...
Ahmet Yılmaz's user avatar
0 votes
1 answer
21 views

How can I print the List of WebElements in Selenium Drag & Drop code?

I need little hepl with the Selenium Drag & Drop code. where List of Element are not getting print please help here codes give below : package com; import org.openqa.selenium.By; import org....
Sanjay Mardi's user avatar
0 votes
1 answer
17 views

Kotlin handle indexOutOfBounds for nested list objects

I have an nested list objects. like the one below. How do I avoid indexOutOfBounds exception? Is there a idiomatic way to do it? listA[0].listB[0].listC[0].department
Droidme's user avatar
  • 1,197
1 vote
1 answer
30 views

Taking User Input in one line and store in the ArrayList in multiple variables [duplicate]

I am trying to take User Input in one line and store in Array List. For Example I want to take User Input to sort the maximum and Minimum values of the given input. I am looking for some code ...
Jeevan Jitu's user avatar
0 votes
1 answer
22 views

Calculating max difference between consecutive elements in a specific column of a list of lists in Python without pandas

I have array that is a list of lists. Each list index of the list is representative of a specific 'column' of data. I need to find the max difference between any two consecutive elements in 1 specific ...
jwatki8's user avatar
1 vote
1 answer
20 views

can't use add() in array list or make "String arrays"

import java.util.*; public class Player { ArrayList<String> paths = new ArrayList<String>(); // Create an ArrayList object paths.add("src/images/pacman.png"); ...
Perseus's user avatar
  • 11
0 votes
0 answers
45 views

Why is it when I try using a for loop on an ArrayList, it keeps giving me an IndexOutOfBoundsException error even though I am starting at 0? [duplicate]

Before I get into anything, I just want to say that I am a newbie to Java (1 year) and Stack Overflow (about a few months), so if I am doing something wrong, please let me know! Anyways, lets get into ...
TimMcCool's user avatar
-2 votes
1 answer
76 views

Convert List to Map of Map

I have an object array like below. [ { "defName": "Project", "defDesc": "Project 1", "defID": "abcd123", ...
iCode's user avatar
  • 8,842
1 vote
1 answer
7 views

Error: char cannot be converted to string

Help me understand and fix the error please. I've commented the line in which error occurs. import java.util.*; public class Main { public static void main(String[] args) { Scanner sc= new Scanner(...
Hritikesh S Shendre's user avatar
0 votes
0 answers
27 views

how to convert json to ArrayList<ArrayList<String>> in java like JsonConvert.DeserializeObject<List<List<object>>>(jsonstr) in c#

How to convert json to ArrayList<ArrayList> in java. Corresponding c# code using NewtonJson is like: JsonConvert.DeserializeObject<List<List<Object>>>(jsonstr) But what would ...
Orgil's user avatar
  • 187
0 votes
1 answer
30 views

RecyclerView crashs in API 28 when ArrayList is filled with datas, in API 33 not

Kotlin: RecyclerView crashs in API 30 (also in 26 and 28) when ArrayList is filled with datas, in API 33 not. What is wrong? Although minSdk 26 is specified in Android Studio the app crashes in API 30 ...
Dr. Wo's user avatar
  • 1
0 votes
0 answers
46 views

ModelMapper error-org.hibernate.AssertionFailure: force initializing collection loading: Spring Boot and JPA

I am working on a Spring Boot Project. I have 3 entities- @Entity @Data public class Author { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name="Author_id") ...
coder001's user avatar
  • 335
0 votes
2 answers
35 views

How to obtain an object from an arrayList by matching with one of the fields and not by the index in java

Good morning. Currently I have an ArrayList called Account that has several parameters and within it has fields of the ArrayList type (attribIdenCtaUsos), what I want is to obtain certain parameters ...
Cesar Justo's user avatar
0 votes
2 answers
50 views

Understanding the use of true/false for boolean in Kotlin

I need some help understanding a part of a Kotlin course that Im watching and Im a complete beginner in coding. So at some point the instructor creates a class called "Loot" and he wants to ...
Kianush Ghahari's user avatar
0 votes
1 answer
24 views

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 occuring in my Activity's Adapter

When I started the MainActivity, my app crashed and returns the error : java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 on my stack trace. Here's my adapter code: class MainAdapter: ...
Bryant Anthony's user avatar
1 vote
2 answers
82 views

Unable to perform mathematical operations on Java List

I am new to Java and need some clarification on handling List / ArrayList based on values that are added to the list from user inputs. User inputs are obtained from a UserInput class with a ...
Ry123's user avatar
  • 64
0 votes
2 answers
38 views

How to access to the inner ArrayList<Any> binded by an initial ArrayList of type <Any>

I am trying to access to the inner ArrayList in Kotlin... Please refer, herein. Is there a way? Many Thanks fun main() { val y = ArrayList<Any>() for (i in 1..2){ y.add(...
Meerza Al Fardan's user avatar
0 votes
2 answers
47 views

ArrayList sorting after remove a specific item

i need to sort the elements of an ArrayList oredering from the elements who is next to the removed one. somethink like this: if i have Arraylist list = [ obj1 , obj2 , obj3, obj4 ] and i remove from ...
Manuel Fiorentini's user avatar
-2 votes
1 answer
34 views

whty is my hashmap adding duplicate details

I have this block of code. I need to return hashmap that has the gender as key,and another hashmaap value the second hash map has yearofbirth as key and arraylist of all people with that saame ...
hsn saed's user avatar
1 vote
1 answer
22 views

Ansible add list items to list dictionaries

I have these data structures - several lists from which I build the list of dictionaries: TASK [debug] ******************************************************************* ok: [26.167.26.11] => { ...
Tomáš Halagan's user avatar

1
2 3 4 5
688