Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
1 vote
2 answers
57 views

How to add an ArrayList in a Superclass using Getters and Setters from a subclass

Here is the super class: public abstract class ImperialCluster implements Serializable,Clusterable { private static final long serialVersionUID = 1L; private String clusterType; ...
Tomas Gutierrez's user avatar
-1 votes
1 answer
37 views

How to filter objects from list based on uniqueness of object property?

I have a list of Person objects. Each Person object has an int id property, along with some others. Currently my list of Person objects has multiple objects with the same id. I want to filter the list ...
Kevin2566's user avatar
  • 423
-1 votes
0 answers
29 views

Java add method is not working during arraylist iteration [duplicate]

Add method is not working in Iteration of arraylist but remove method is working in iteration of arraylist. package thread; import java.util.ArrayList; import java.util.Iterator; import java.util....
Santhosh Kumar's user avatar
-3 votes
1 answer
31 views

Previous objects in the list of objects are getting modified on adding the last object to the list [duplicate]

Why the previous objects get updated when last element is added in the list? I am creating the objects inside the loop, setting their properties, adding them to their list. But upon adding the last ...
mukul anand's user avatar
-1 votes
0 answers
27 views

How to see if arraylist of a class contains a specific value [duplicate]

I am working on a java project, I have an ArrayList of a custom class with two variables (a boolean and char) I need to check if it contains a specific char. How do I get it to check the char of it. ...
Arceus Insanity's user avatar
-1 votes
4 answers
83 views

ArrayList sublist method clarification

This is regarding the usage of subList method in an ArrayList. Consider I am having an array as below:- int[] prices = {71,11,65,99,21,82}; I am converting the above array to arrayList as below:- ...
user3153356's user avatar
0 votes
0 answers
26 views

How do I fix this nullPointException exception in my program? [duplicate]

I'm trying to create a simple card game where the user faces against a computer (which is a class in my method that takes its turn automatically after the user), but I'm encountering a ...
Emily Araoju's user avatar
-1 votes
1 answer
114 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[] ...
ktm5124's user avatar
  • 12k
-4 votes
1 answer
64 views

Why is my code giving wrong answer when using 2d ArrayList and passing when using 2d arrays?

Here is the DP question, Given a ‘N’ * ’M’ maze with obstacles, count and return the number of unique paths to reach the right-bottom cell from the top-left cell. A cell in the given maze has a value '...
Anonymous's user avatar
-1 votes
2 answers
42 views

Type mismatch: inferred type is OnSuccessListener<ArrayList<myClass?>> but OnSuccessListener<in ArrayList<myClass>!> was expected

I am trying to convert Java code to Kotlin code but in a code segment in particular it seems is not posible to fully convert. I am getting a Build error: Type mismatch Required: OnSuccessListener<...
jetberrocal's user avatar
0 votes
1 answer
72 views

enum float problem calculating price of coffee [closed]

package Main; import java.util.ArrayList; import java.util.List; public class Main { List<Ingredients> ingredients = new ArrayList<>(); public enum Ingredients { ...
Örlygur Hugason's user avatar
1 vote
3 answers
124 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 ...
Andrey Voeyko's user avatar
0 votes
1 answer
49 views

how to connect a Arraylist to one Index from an another Arraylist

im a bigginer for coding and java. Im now learning about Hashtable. What im struggling here ist to connect a ArrayList to one of the index from an another ArrayList. a simple image of what I want to ...
happy day's user avatar
0 votes
1 answer
72 views

Undeclared variable when trying to use get() on Arraylist

I am trying to filter out specific elements of my array list but I keep getting an undeclared variable error. public class Student { private String name; private int age; private double ...
Jourdie Browne's user avatar
0 votes
1 answer
80 views

making a simple calculator but the input is in one line (newbie)

package kotauto; import java.util.ArrayList; import java.util.Scanner; import java.util.concurrent.TimeUnit; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException;...
Bartek Kopyt's user avatar

15 30 50 per page
1
2 3 4 5
1766