Skip to main content

All Questions

Tagged with
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 ...
Mantas Vidutis's user avatar
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 ...
Kalina's user avatar
  • 5,554
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[]?
kamikaze_pilot's user avatar
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?
Samuel's user avatar
  • 4,377
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....
django's user avatar
  • 213
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'...
Sergey's user avatar
  • 2,890
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(...
Prats's user avatar
  • 1,515
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 ...
user1855952's user avatar
  • 1,545
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 ...
H J's user avatar
  • 369
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? ...
Serv0's user avatar
  • 181
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 ...
user1253201's user avatar
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. ...
Dan S.'s user avatar
  • 87
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 ...
Debugger's user avatar
  • 762
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] = ...
JamesB's user avatar
  • 493
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 ...
Mark Denn's user avatar
  • 2,294

15 30 50 per page
1
2 3 4 5