arraylist

How to iterate an Arraylist inside a HashMap using jstl?

I am having map like this, Map<Integer,ArrayList<Object>> myMap = new LinkedHashMap<Integer,ArrayList<Object>>(); Now i have to iterate this Map and then the ArrayList inside the map. How can i do this using jstl. ...

Compare/count values in a System.Collections.ArrayList

I'm scrubbing 5 files for a specific value. I dont anticipate any different values, BUT since this is for my own educational purposes, I would like the application to count, compare and print the most popular value. for example: ArrayList arrName = new ArrayList(); arrName.Add("BOB") arrName.Add("JOHN") arrName.Add("TOM") arrName.Add(...

ArrayList Confusion and assistance!

hi, basically id like a few hints or tips on how to solve this question.. maybe a few things which i could read up on about arraylists and loop which would make it simple for me to understand!.. the question is : Processing an ArrayList of Characters: cList is an ArrayList of objects of type Character that has been declared and in...

java: ArrayList - how can i check if an index exists ?

Hi. I'm using ArrayList and i add data in specific indexes, how can i check if a specific index exists ? should i just get() and check the value or wait for an exception or is there another way ? update thank you for your answers but i add stuff in specific indexes once i will add at index 8, other times at index 2. the length of th...

Java Float become 0.0 after adding to ArrayList<T>

I have the following object : class Repeat{ private long startIndex; private long endIndex; private int length; private float repetitions; private float period; private int errors; private float percentOverlap; public void setPercentOverlap(float percentOverlap) { this.percentOverlap = percentOve...

Efficiently filter an ArrayList in Java/Android

Hi, I'm developing an Android app (Android 1.6), but this is probably a more general Java question. I have an ArrayList of about 10,000 objects the objects contain 3 strings (firstName, middleName, lastName). The user is presented with a "search box" on android where they can search for a particular "object" by typing in part of the n...

Converting an ArrayList into a 2D Array

In Java how do you convert a ArrayList into a two dimensional array Object[][]? From comments: I will describe you the problem with more details: an XML file includes a list of contacts (e.g. name, address...). The only way I can obtain this information is through an ArrayList, which will be given to me. As I need to store the content...

Prevent ArrayList.Add() from returning the index

Hi, is there a way to supress the return value (=Index) of an ArrayList in Powershell (using System.Collections.ArrayList) or should I use another class? $myArrayList = New-Object System.Collections.ArrayList($null) $myArrayList.Add("test") Output: 0 thanks in advance Milde ...

Which one is faster DataTable or ArrayList? searching point of view.

i have got any no of records in datatable with id field and other fields.. and i have got a arraylist which have got all id of datatable's records.. now i need to check that the perticular id exist in records or not.. for that i can check in datatable or i can check in arraylist (because arrylist also contain all those ids).. so please t...

How can I determine the type of object an ArrayList iterator will return next?

I have an ArrayList and I am using an iterator to run through it. I need to find out what type of object is next: Iterator vehicleIterator = vehicleArrayList.iterator(); while(vehicleIterator.hasNext()) { //How do I find the type of object in the arraylist at this point // for example, is it a car, bus etc... } Thanks ...

Time complexity for java ArrayList

Is ArrayList an array or a list in java? what is the time complexity for the get operation, is it O(n) or O(1)? ...

Problem In count field in Arraylist and save it

Hi, well, I have an ArrayList with this values ACU ACU ACU ACU ACY ACY AER AER AER AGC I need to get the number of items of each Word, so for ACU we will get 4, ACY we will get 2, AER we will get 3, AGC we will get 1. Generally the number a word is repeated is a variable so another time ACU could be 1,and ACY could be 100.. So., ...

Pros and cons between ArrayList and Arrays.

When to use ArrayList and when to use Arrays? ...

Problem counting in Map<String, Integer>

Hi, I asked a question about counting the number of times a word is in ArrayList: ACU ACU ACU ACU ACY ACY AER AER AER AGC So for ACU we will get 4, ACY we will get 2, AER we will get 3, AGC we will get 1. I got some help but I cannot make it work. Darren gave me a very important answer: Map<String, Integer>wordCount = new HashMap<...

Pulling $_POST array elements into sequential variables with a common prefix

I have a $_POST array that results from selecting (in this case) 3 rows from a displayed HTML table in which each row has a checkbox. The IDs are unique identifiers for each row. Array ( [checkbox] => Array ( [0] => 001403166 [1] => 001407509 [2] => 001407541 ) ) I want to gathe...

Sort ArrayList of custom objects by String member

I'm having a issue sorting an arraylist of custom objects by a string field. This is the code I'm trying to do: arrRegion.Sort(delegate(Portal.Entidad.Region x, Portal.Entidad.Region y) { return x.RegNombre.CompareTo(y.RegNombre); }); But I'm getting ...

How do I copy an arraylist from one class to another in Java?

I understand that in order to copy an arraylist and have two lists independent of one another you must use a deep copy (copying the objects from one list to another not just the references), however is there a way this can be done cross-class? For example; I am calling Class2 from Class1. In Class2 objects are added to an ArrayList of c...

Android How do i overwrite the filter for my ArrayAdapter?

Hey guys my first post here... Im trying to write a custom filter to filter the arraylist in my arrayadapter such that my listview is filtered when i click on the button. For instance when i click on my button public void onClick(View arg0) { String abc = "abc"; m_adapter.getFilter().filter(abc); } How...

Duplicates in Arraylist, comparing various fields java

hi forum. I have a code to return an arrayList with the duplicates of an ArrayList but seems it{s not working, I am comparing all items in the array... Sorry, I entered wrong code, I edited :) public ArrayList<ObjectList> duplicates(ArrayList<ObjectList> someObjectsList) { ArrayList<ObjectList> ret = new ArrayList<ObjectList>(); ...

Java: Adding to an array list

public class Maze { public static final int ACTIVE = 0; public static final int EXPLORER_WIN = 1; public static final int MONSTER_WIN = 2; private Square[][] maze; private ArrayList<RandomOccupant> randOccupants; private Explorer explorer; private int rows; private int cols; public Maze(Square[][] maze, i...