arraylist

Objective-C NSMutableArray of sockets?

Hey guys, I want to store a couple of sockets in an ArrayList/NSMutableArray, but the sockets are of type int and NSMutableArray only accepts objects (id). Is there another data type that I can use as a container for sockets? I am not sure how many entries I will have, so I would like the data container to be like an ArrayList. Thanks!...

object strorage capacity Array list

What are the consequences if we store huge objects collection in Arraylist when it is not expecting them (i.e we may initialized the Arraylist to accommodate 10/100/1000 objects, however at runtime we might store some 100 thousand objects). and which is better out of below two in case we know this will happen at some point of time. 1).T...

How does ArrayList work?

What data structure does an ArrayList use internally? ...

Java: How do I sort multiple ArrayList by their size?

I have 9 different ArrayList and I want to have a list of the top 5. I'm thinking of sorting those ArrayLists by their sizes. Is it possible to do that? If so, how can I achieve that? After a few try i finally got it working, just want to share it with everyone. it will be better to get the size of the arraylist and add it to th...

how to define an arrayList with two columns in java?

I have a hashMap. Each "Value"is going to be a a list which will be mapped later on with my "Key"s. List is desired to look like this: [length,time][length,time][length,time] For example: Key{srcAddr=x, dstAddr=y, srcPort=12345, dstPort=80} value{(6523,0.001),(124,0.05), () , (), ...} I just wonder how can I have a two-col arrayList. ...

Converting ArrayList of objects to ArrayList of this objects String names in Java

I have an ArrayList of User objects. Now I need the ArrayList of these user's names only. Is there a way to use toString() on entire ArrayList and convert it to ArrayList of String names rather than doing this in for loop? I have also overridden toString in User class so it returns user's name, and I have tried ArrayList <String> names =...

Is it possible to add two IQueryable's together?

I've been using Union on IQueryable<> (with the same type) to try to get one collection produced from two collections, but it is not working. I believe my understanding is at fault with regards to the IQueryable members. I thought I could use the union method to build (within a foreach) a SQL statement which would execute something like...

Sync multiple source ArrayLists into single target list

Hi, There is a requirement to load a list of items(ArrayList) from two different tables. Due to complex Hibernate mapping, they can not be loaded as one ArrayList. So they are loaded separately by two different Hibernate bags in the class definition. When I use them I'd like to combine into single list. So I am thinking about writing a ...

Java - remove last known item from arraylist

OK so here is my arraylist. private List<ClientThread> clients = new ArrayList<ClientThread>(); and here is what i am trying to do. I am trying to remove the last known item from the arraylist i posted above... doing this: } catch(SocketException re) { String hey = clients.get(clients.size()); ...

Java - remove last known item from HASHMAP on MAP!s

OK so this is a BIT different. I have a new HashMap private Map<String, Player> players = new HashMap<String, Player>(); How do I remove last known item from that? Maybe somethign like this? hey = Player.get(players.size() - 1); Player.remove(hey); ...

Java: What object is more appropriate?

Hi, I am writing an application similar to a chat server-client pair. I am planning on having a central Object which will hold new messages received from clients until they are dealt with by the main thread. My application is multi-threaded. Each client will be on its own thread, so multiple threads will be adding messages to this cen...

Correct way to add objects to an ArrayList

I am trying to add an object to an arraylist but when I view the results of the array list, it keeps adding the same object over and over to the arraylist. I was wondering what the correct way to implement this would be. public static ArrayList<Contact> parseContacts(String responseData) { ArrayList<Contact> Contacts = new Arra...

Does this NullPointerException refer to getFoos returning null or some problem with the cast from a Collection to an ArrayList?

Why does this line cause a NullPointerException: List<Foo> foos = new ArrayList<Foo>(userDetailsService.getFoos(currentUser)); The getFoos method simply returns a Collection of Foos: public Collection<Foo> getFoos(final String username) I can't tell if the NullPointerException refers to getFoos returning null or some proble...

ArrayList.remove(int index) not working with non-anonymous class object

Hi All, ArrayList.remove(int index) is working with the anonymous instance of ActionListener class :- DeleteModule.java :- import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JOptionP...

C#, ArrayList Property to List field

Hello, I have the following Field: private IList<Modulo> modulos; and the following Property: public virtual ArrayList XmlModulos { get { if (modulos == null) return new ArrayList(); var aux = new ArrayList(); foreach (Modulo m in modulos) aux.Add(m); ...

dynamic 2d array in java using Arraylist

I found some problem in creating dynamic 2d array with arraylist,The original code is tediously long to read so i am giving a simple code here,the problem is same in both the cases: import java.util.*; class test{ public static void main(String args[]){ Integer test[]=new Integer[3]; ArrayList<Integer[]> al=new ArrayList<Inte...

Split and echo into a list

i have a sql table full of address' like this Hattie:07903 000066::Dad:07854 000095::Tom:07903 000044::Allistair:07765 000005::Home:0115 974 0000:: i would like to split each and every one so that the name and number of each contact is echoed into a seprate panel within a listbox like below <ol> <li>Hattie:07903 000066</li> <li>Dad:0...

Java ArrayList looking for multiple strings

Let's say I have two same strings inside an ArrayList... is there a way to check for that? Also is there a way to check for how many times a string of the same exact is in the ArrayList? So let's say I have the following a ArrayString. os.println(itemIDdropped + "|" + spawnX + "|" + spawnY + "|" + currentMap + "|drop|" + me.getUsername...

Best practice concerning private arraylist and other such constructions

Hello all, I have the following class which I'm fighting over how to implement. The question is whether or not it makes sense to have a private collection item, in this case an arraylist, a a member. I am well aware it is considered best practice to have getters and setters for any class members, but in this case having a getter and set...

what to use in multithreaded environment; Vector or ArrayList

I have this situation: web application with cca 200 concurent requests (Threads) are in need to log something to local filesystem. I have one class to which all threads are placing their calls, and that class internally stores messages to one Array (Vector or ArrayList) which then in turn will be written to filesystem. Idea is to retu...