34,560 questions
Best practices
0
votes
4
replies
120
views
Best method to loop a list while removing items
I have a list of ranges that consist of a start and end value. I need to optimise the list by identifying any overlapping ranges and merging them so that there is no duplication on the list.
I have ...
0
votes
3
answers
107
views
Reversal of Linked List with head and tail node recursively
I am working on a LeetCode question. I am able to solve it using other approaches but not via this approach.
I am trying to reverse a singly linked list recursively.
When I run the code, my output for ...
0
votes
1
answer
87
views
Constructor not accepting list of derived class as argument [duplicate]
I have tried using both base class and interface and in both instances I am told a constructor that takes my arguments does not exist. I have two classes that are related to each other and I want to ...
0
votes
1
answer
158
views
Make array of variables with osclass custom category values
How can I make an array of variables generated using the values passed through a while loop ?
I am using osclass for a uni project and I find no way whatsoever to make a list os usable variables from ...
1
vote
1
answer
75
views
Framing verification issue on mutable array in a typical ArrayList Insert operation
Consider the following simple ArrayList implementation:
class ArrayListImpl<T(0)> {
var xs: array<T>
var n: nat
predicate Valid() reads this
{ 0 <= n <= xs.Length }
...
5
votes
3
answers
209
views
How to consistently retain an exact percentage of elements from a List in Java?
I'm currently filtering a Java List to keep approximately a percentage of its elements using a random approach:
import java.util.List;
import java.util.Random;
public class Main {
public static ...
1
vote
1
answer
93
views
Trying to create nested lists of text data based on test group and questionnaire response, then return the total number of each type of response
My macro accurately creates 2 lists of numerical data based on which group (control or exposed) a subject is in.
Dim Subjects As Integer
Subjects = Sheets("Participant Info").Range("C4:...
1
vote
1
answer
70
views
Excel Macro only returns last value in an array
I have a list of 36 subjects and their ages, and whether they are in the 'Control' or "Exposed" group. I am trying split this list into two based on what group they are in. The program ...
3
votes
3
answers
374
views
ArrayList vs LinkedList in terms of cache locality
How does cache locality impact the performance of ArrayList compared to LinkedList in Java?
I've often heard that ArrayList has an advantage in terms of cache locality, but I don't fully understand ...
0
votes
1
answer
78
views
Backtracking confusion
Concerning Javascript, I've been trying to understand backtracking lately and it's really confusing. Specifically, I've been trying to understand the permutation problem, which when given an array, we ...
3
votes
2
answers
180
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 ...
1
vote
1
answer
57
views
LINQ Query to find items that contain a value in an array of values
I have a text property in a class that will contain multiple words along with other properties (index, linenumber, starttime, endtime). I have an arraylist (rawdata) of that class built.
I need to be ...
1
vote
1
answer
93
views
Java with Playwright onResponse method - can't get returned String value, IndexOutOfBoundsException
I have created a void method which prints out the required responses from an url (using Java and Playwright) but I actually need to receive these values for making junit assertions and I am trying to ...
2
votes
3
answers
275
views
What does this piece of code mean? new ArrayList<>(Collections.emptyList())
In some code from my company, I've read a list initialization:
List<SomeClass> someClassList = new ArrayList<>(Collections.emptyList())
What does it mean? A list with 0 size ...
0
votes
1
answer
74
views
Stack Overflow on Quicksort with a first element pivot in Java
For this assignment I'm supposed to test my quicksort class using a variety of different pivots and a variety of ArrayLists in different arrangements. The class works fine with a random pivot, or a ...
2
votes
3
answers
96
views
How to check if the user has purchased the maximum capacity?
I have a Java code for booking movie tickets. In this program, each person can only buy two tickets, a maximum of 10 tickets are sold and at the end it displays a list with the names of the people. I ...
0
votes
0
answers
55
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
148
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 ...
1
vote
2
answers
91
views
Sort a multidimensional array/arraylist/hashtable
Currently I have the below code creating a multidimensional arraylist (but I am not married using arraylists, just need a free-to-add to array type):
$Installs = new-object system.collections....
0
votes
0
answers
30
views
Read in bitmaps from file arraylist to bitmap arraylist [duplicate]
How do I extract image urls from a file arraylist and add the corresponding bitmap to a bitmap arraylist. I've blocked out what I think is close:
val fileList: ArrayList<File> = imageReaderNew(...
0
votes
0
answers
37
views
list - filter condition working in one scenario but not another
I have two arrays both contain 12 elements. I want capture the elements with the indexes of 0, 5, 10 and store them in a new variable, but I've noticed my filtering does not work if I change some of ...
5
votes
2
answers
160
views
Read data into an arraylist [closed]
I made a very simple program with a GUI where the user inputs the file name and the program itself calculates the mean of a file containing numbers only. I did this by creating a function that reads ...
0
votes
1
answer
259
views
Error with @Type Annotation for JSON Mapping in Spring Boot and Hibernate
I'm working on a Spring Boot application that needs to map a JSON column in my MySQL database to a Java entity using Hibernate. I am using the @Type annotation from the Hibernate Types library, but I'...
1
vote
1
answer
71
views
Given two Json list how to remove the fields in JSon which are null and not present in the Json list named parsedXmlChild and store it in a new list?
parsedJsonChildData (original data): [{date=null, feeForPerformance=null, feeFrequency=5}, {date=12-25-2024, feeForPerformance=23, feeFrequency=1}, {date=12-03-2025, feeForPerformance=1, feeFrequency=...
-2
votes
1
answer
88
views
Define a object to be unique in a Set, irrespective of order of List elements within the given object
I have a Class B defined as below -->
Class B {
private List<String> obj1;
private List<A> obj2;
// Need to implement hashcode() and equals() methods
}
In my code, I am using ...
0
votes
1
answer
102
views
C# How to Group List for XML Object
I need help, for group by my XML object class.
Here my data from SQL server, my Query
( select * from TaxXMLdb ) =
TIN
DocEntryAR
BuyerDocNum
BuyerName
Opt
ItemCode
Name
DocEntryAR2
AAA
100100
5533
...
2
votes
3
answers
145
views
How to make this while loop create a list of objects?
The following code is meant to loop through a txt file and create a list of recipes that each have a name, cooking time and ingredients, which are themselves put on a list
try (Scanner scanner = new ...
0
votes
1
answer
46
views
How to solve a problem with generalized types more correctly
My program has 5 classes:
1 - Abstract class Animal
public abstract class Animal {
}
2, 3 - Classes that extend an abstract class
public class Cat extends Animal implements Comparable<Cat> {
//...
1
vote
0
answers
56
views
How to remove an Arraylist row when it is not located in Main Activity
I have created an Arraylist of items. Once an item is selected, it goes to a new activity for the price to be calculated once the quantity is selected. Upon clicking cart, it goes to another activity ...
0
votes
0
answers
115
views
How to repair a file with java.io.EOFException
I'm not sure what happened when saving a file, but now when I try to load it I get java.io.EOFException. All of the code is in try/catch blocks but there was no error when saving the file.
Opening the ...
-1
votes
1
answer
69
views
Max product of a sublist of a list in python
This image contains Question Sorry can't provide in text as it can not be copy from the platform
enter image description here
This is what I tried
Test cases
I was Having Problem solving Test case 2 ...
0
votes
1
answer
37
views
how to access each json object in a array using for loop?
{
"item1" : [{"index":"1"},{"id":"1","name":"npm","result":"expected text1"},{"id":"2",&...
0
votes
1
answer
53
views
about javascript 'open.window' return value diff
on firefox or chrome.
open the console
let arr = []
arr.push(window.open('https://google.com'))
arr.push(window.open('https://twitter.com'))
arr[0].close()
don't work
arr[1].close()
is work
...
0
votes
0
answers
46
views
Automatically update entries in an sql database table based on the values of another table
there's this thing where the program has to automatically change an item's column's value in a table based on their Type ID. Basically
-Maintenance Sched Table has Type ID and No. of Days
-Items Table ...
0
votes
0
answers
26
views
get-method of an array list gives "object" and not specific class back [duplicate]
I try to manage an Array list of AccessCodes, which are a simple class. In the class Robot I want to get access of one element of the ArrayList and use the method getUsed(), which is defined in the ...
-5
votes
1
answer
109
views
I need to compare 2 csv files with 300000+ text and find matches, then display the matches on the screen. Sheet printing outputs 177232-300000+ [duplicate]
I'm reading two CSV files from my computer and filling an arraylist with this data. Then I compare these two arraylists to find matches.
If the CSV files contain up to 20 lines, then there are no ...
0
votes
2
answers
128
views
How can I check all the prime numbers in a for loop?
I want my program to take an integer and put every prime number up to that integer into an ArrayList. Logically I can't find why it doesn't work.
import java.util.ArrayList;
public class primenumbers ...
0
votes
1
answer
536
views
Zig - Appending values to an ArrayList inside while loop override all values to the last entry fractions
Using Zig, as a new to the language, trying to perform few simple actions on a file.
I have a function with the purpose of getting a path to a file and returning path to a sorted file.
The function ...
-2
votes
1
answer
92
views
How to filter data from list of objects from response?
I have a response. I need to get the functionAmount when functionType = limit. I have the hard coded here. How to convert this into dynamic. How to filter data from nested objects?
"users": [...
-2
votes
1
answer
755
views
com.fasterxml.jackson.databind.exc.MismatchedInputException when trying to read a json file
I am trying to write an endpoint to return all the data in a seperate JSON file.
This is my code for now.
UserController.java
import org.springframework.beans.factory.annotation.Autowired;
import ...
-1
votes
1
answer
248
views
Difficulties using ArrayList with .NET Framework 4.8 [duplicate]
I'm writing a .vbs script for an application on Windows. The problem is that the ArrayList is used inside the script. MDSN states that the .NET Framework 4.8 installed is sufficient to use ArrayList. ...
1
vote
2
answers
104
views
Looping if statement
I want to loop through an array with an if statement and only after it has looped through the entire array execute the else.
This is how i have my code now
for index, nameList in enumerate(checkedName)...
3
votes
1
answer
65
views
Incorrect calculation in the list processing logic based on dependencies between the elements of these lists
My code gives me this incorrect output:
['CT', 'X', 'Z']
[100, 1.0583, 1.0633]
[200, 3.012, 5.873600000000001]
[300, 1.79, 2.5220000000000002]
['Total', 0, 0]
The reason is that 5.873600000000001 is ...
0
votes
0
answers
41
views
Create Primitive Array from Class Array [duplicate]
I am a C# developer in my day job and I'm working on a side project in Kotlin while trying to learn the language. I am consolidating ArrayLists into a single ArrayList using a class like this.
class ...
-3
votes
1
answer
64
views
TypeError: object of type 'int' has no len(), then i pass list to func
I wanted to write a recursive function that calculates the sum of the elements in an array, but when I pass the array to the function, it thinks that I passed an integer and writes that there is no ...
-3
votes
1
answer
55
views
" java.lang.ClassCastException: android.widget.Button[] cannot be cast to android.widget.Button" i find this issue in runtime in android kotlin
java.lang.ClassCastException: android.widget.Button[] cannot be cast to android.widget.Button at &...
0
votes
1
answer
81
views
Send image file and arrangements with jquery with Formdata and C#
I am trying to send some image files, an array and a list with Ajax, but when I read it in the maintainer, it does not pass me the values of the list, the value is null. The program is developed in ...
1
vote
1
answer
276
views
How to observe changes in a List when the ViewModel is in Java and the UI is in Jetpack Compose (Kotlin)
I am migrating an application from View to Compose. The application was written in Java so I need to migrate the UI to Kotlin.
I prefer to do it as gradually as possible so I'm leaving the ViewModel ...
0
votes
1
answer
72
views
Flutter add different types to a List<Map>
I would like to add multiple types of classes to a List to use it in a DataTable later on. My desire is to sort the specific columns and use buttons inside of it later on to do some actions. How do I ...
3
votes
2
answers
84
views
Getting the wrong value when using the override toString method
I am using an arraylist to hold different shape objects that are a subclass of an abstract superclass. The superclass contains two abstract methods: surface_area and volume respectively. After I add ...