arraylist

How can I slice an ArrayList out of an ArrayList in Java?

How do I get an array slice of an ArrayList in Java? Specifically I want to do something like this: ArrayList<Integer> inputA = input.subList(0, input.size()/2); // where 'input' is a prepouplated ArrayList<Integer> So I expected this to work, but Java returns a List - so it's incompatible. And when I try to cast it, Java won't let m...

Problem with the ArrayList class in Java

Hi, I have a problem with the following code. I obtain the error message Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.rangeCheck(ArrayList.java:571) at java.util.ArrayList.set(ArrayList.java:364) at Test.main(Test.java:17) and I don't understand why. I have a lis...

how to retrieve multidimentional a class element containing multidimentional arrays from an arraylist

Hi, I'm currently working with CodeGear Delphi 2007 under Vista. My application returns out of memory error during some rather heavy calculations. The .exe files grows from 150 Mb to an amazing 2 Gb (! LOL ) Regarding this issue: 1) I'm changing some arrays into arraylist BUT It's giving me some rather difficult issues to re...

Java 2D ArrayList and sorting

I need to sort a shopping list by the aisle the item is located for example: [Bread] [1] [Milk] [2] [Cereal] [3] I am planning to do this with ArrayList and was wondering how to make an 2D ArrayList Bonus questions: any ideas on how to sort by the aisle number? ...

HashMap vs ArrayList performance am I correct

I currently believe that: When you need a structure from which you will be retrieving items randomly - use a HashMap When you will be retrieving items in order (e.g. using a for loop) - use an ArrayList Am I generally correct? Are there situations where this is not correct? ...

What is the reverse of (ArrayList).toString for a Java ArrayList?

I am using the toString method of ArrayList to store ArrayList data into a String. My question is, how do I go the other way? Is there an existing method that will parse the data in the String back into an ArrayList? ...

Memory overhead of Java HashMap compared to ArrayList

I am wondering what is the memory overhead of java HashMap compared to ArrayList? Update: I would like to improve the speed for searching for specific values of a big pack (6 Millions+) of identical objects. Thus, I am thinking about using one or several HashMap instead of using ArrayList. But I am wondering what is the overhead of Ha...

Java - copying arraylist objects

Hi I am trying to copy the contents of an arraylist into another object. I tried initializing the new ArrayList object in the following ways newArrList.addAll(oldArrList); and newArrList = new ArrayList(oldArrList); But every time I make a change to one of the array lists, the value also changes in the other ArrayList. Can someon...

ArrayList content to JLabel

Hi all, If i have an ArrayList of type Integer, containing numbers like 1,3,4,9,10 etc... How can i display those on a JLabel, not the sum, but all the numbers in a sequence. So the JLabel would display, in this case: 134910 Thank you in advance for any help. EDIT: Thank you all, ofcourse i should have thought about append. Anyways, ...

android: problem with Serializable object put into intent

Hi i have problem with a class i want to pass in an intent by putting it into the putExtras() Its serializable and the code looks like this: public abstract class ObjectA extends ArrayList<ObjectA> implements java.io.Serializable{...} public class ObjectB extends ObjectA {...} ... Bundle extras = new Bundle(); extras.putSerializable(...

What is difference between array and ArrayList?

I have a doubt that what is an array and what is an ArrayList? What is the different between them? ...

Java setting values from a Map to a Set

Hello! I am trying to make a method that takes the first Map whose values are sets and a second empty Map whose values are Lists and fills the second Map with the same key/value Mappings as the first. The 2nd map will have every key in the 1st Map, but associated with it is a List of all the same elements that are in the Set it maps to. ...

Multi-dimensional arraylist or list in C#?

Is is possible to create a multidimensional list in C#. I can create an multidimensional array like so: string[,] results = new string[20, 2]; but I would like to be able to use some of the features in a list or arraylist like being able to add and delete elements. ...

How to return ArrayList type from DomainService Class to CLient Side?

Hello, Background: 3-4 weeks experience in Silverlight3/C#/.Net and about 3days worth with the RIA Services concept. (most of my previous questions up to date should explain why) I am doing a test implementation of Microsoft's RIA services with Silverlight3. This is part of a proof of concept i have to do for a client. So its very basi...

Why does this code throw an IndexOfOutBoundsException - aka, what's up with ensureCapacity()?

Consider the following two snippets of code: int index = 676; List<String> strings = new ArrayList<String>(); strings.add(index, "foo"); and int index = 676; List<String> strings = new ArrayList<String>(); strings.ensureCapacity(index); strings.add(index, "foo"); In the first case, I'm not surprised to see an IndexOfOutBoundsExcept...

C# Windows Form ComboBox Array Code.

I am using C# with a Windows Application Form. In this I have a combobox. What is the code to add the dropdown selections? From my googling so far I presume I need to setup an arraylist for the details? ...

Display pairs in Random order

Hi everyone, How can I randomised the order of pairs? e.g. I have 3 elements stored in list e.g. A,B,C --> which makes pairs of A-B, A-C, B-C. How can I display the pair in Random order? e.g. A-B, A-C, B-C or B-C, A-B, A-C or A-C, A-B,B-C ArrayList<String> s = new ArrayList<String>(); s.add("A"); s.add("B"); s.add("C"); ListGen...

GWT + JDO + ArrayList

Hi, I'm getting a Null ArrayList in a program i'm developing. For testing purposes I created this really small example that still has the same problem. I already tried diferent Primary Keys, but the problem persists. Any ideas or suggestions? 1-Employee class @PersistenceCapable(identityType = IdentityType.APPLICATION) public class Em...

Importing from Text File Java question

Hi all, I decided to create a currency converter in Java, and have it so that it would pull the conversion values out of a text file (to allow for easy editability since these values are constantly changing). I did manage to do it by using the Scanner class and putting all the values into an ArrayList. Now I'm wondering if there is a w...

final arraylist declaration

when i declared final arraylist() then can i perform insert,search and update operation in that arraylist or not??please reply me... thanks in advance ...