All Questions
71
questions
323
votes
10
answers
601k
views
How does a ArrayList's contains() method evaluate objects?
Say I create one object and add it to my ArrayList. If I then create another object with exactly the same constructor input, will the contains() method evaluate the two objects to be the same? Assume ...
54
votes
5
answers
56k
views
How to save custom ArrayList on Android screen rotate?
I have an ArrayList with custom objects that I would like to be able to save and restore on a screen rotate.
I know that this can be done with onSaveInstanceState and onRestoreInstanceState if I ...
236
votes
7
answers
202k
views
make arrayList.toArray() return more specific types
So, normally ArrayList.toArray() would return a type of Object[]....but supposed it's an
Arraylist of object Custom, how do I make toArray() to return a type of Custom[] rather than Object[]?
61
votes
3
answers
363k
views
Creating an Arraylist of Objects
How do I fill an ArrayList with objects, with each object inside being different?
14
votes
5
answers
43k
views
Remove object from ArrayList with some Object property
I am maintaining one ArrayList of objects. And my object structure is Id, name, some other details. I need to remove one the object with some id value say(10) and I don't want to iterate over the list....
30
votes
6
answers
64k
views
Finding out if a list of Objects contains something with a specified field value?
I have a list of DTO received from a DB, and they have an ID. I want to ensure that my list contains an object with a specified ID. Apparently creating an object with expected fields in this case won'...
4
votes
3
answers
34k
views
Does rest supports arraylist of objects?
I am having a class BookMain which is returning an arraylist of objects. I am using REST service to get the output, but I am getting an error.
This is my BookMain class:
@GET
@Path("/get")
@Produces(...
23
votes
3
answers
109k
views
Using and declaring generic List<T>
So I'm working in Java and I want to declare a generic List.
So what I'm doing so far is List<T> list = new ArrayList<T>();
But now I want to add in an element. How do I do that? What ...
6
votes
4
answers
70k
views
Java, call object methods through arraylist
Based on this question Increment variable names?
I have an arraylist 'peopleHolder' which holds various 'person' objects.
I would like to automatically create 'person' objects based on a for loop.
I ...
9
votes
5
answers
31k
views
java ArrayList contains different objects
Is it possible to create
ArrayList<Object type car,Object type bus> list = new ArrayList<Object type car,Object type bus>();
I mean add objects from different classes to one arraylist?
...
7
votes
6
answers
12k
views
How to sort an arraylist of objects java?
So I want an arraylist of objects in java.
I have object1.number and object2.number, object3.number, etc... but those objects have other properties besides number, such as name, distance, etc...
So ...
4
votes
3
answers
11k
views
How can I correctly remove an Object from ArrayList?
I’m trying to remove an object from an ArrayList. Each Item object has 3 attributes; 1. itemNum 2. info 3. cost. I also have 3 classes, 1. Item class defines the single items stored in the catalog. 2. ...
1
vote
1
answer
5k
views
Need to add multiple items in list - decision table - Drools
I need to create a new multiple instance of objects for the Pojo class in drools decision table. I have implemented using two facts Student fact and subject fact class. I need to fire all the rules in ...
18
votes
4
answers
98k
views
Cannot apply indexing with [] to an expression of type `object'
Here is my code: An ArrayList of ArrayList that returns a float:
public ArrayList walls=new ArrayList();
public void Start()
{
walls[0] = ReturnInArrayList(279,275,0,0,90);
walls[1] = ...
8
votes
4
answers
96k
views
C# objects in arrayLists
I'm working with ArrayList in C# and I am wondering how I can add objects to an ArrayList and then retrieve the values from it?
In short, how can I add, delete, edit and read from an ArrayList ...