ArrayList 4 « ArrayList « Java Collection Q&A

Home
Java Collection Q&A
1.algorithm
2.array
3.Array Byte
4.Array Char
5.Array Convert
6.Array Dimension
7.Array Integer
8.Array Object
9.Array String
10.ArrayList
11.collection
12.comparator
13.Development
14.Garbage Collection
15.Generic
16.hash
17.HashMap
18.HashTable
19.iterator
20.LinkedList
21.List
22.Map
23.queue
24.Set
25.Sort
26.tree
Java Collection Q&A » ArrayList » ArrayList 4 

1. problem in arraylist    coderanch.com

Vijayz, I'm not exactly sure I got your question, however, keep in mind that Lists may contain duplicate values. On the other hand, Sets cannot contain duplicate values. Perhaps you can work with Sets if you don't want duplicate values (or copy the values to a Set and check its size compared to the List). Regards. Rodrigo

2. ArrayList    coderanch.com

// 1: using iterator() for (Iterator i = list.iterator(); i.hasNext(); ) { Object o = i.next(); // do something } // 2: using get for (int i = 0, size = list.size(); i < size; i++) { Object o = list.get(i); // do something } // 3: for-each loop, available since Java 5.0 for (Object o: list) { // do something ...

3. Help with ArrayList    coderanch.com

People, I populei data so that it can facilicitar understanding of those who can help me. This code put the main method blank just getting the list of data to be implemented according to the suggestions of you. What do I need? Order by my data terminal and a date for example: Terminal 1 - "Data 1" Dados... Total valor por ...

4. behaviour of add() of ArrayList    coderanch.com

5. Conceptual Misunderstanding of Arraylists?    coderanch.com

Hey all, I'm trying to implement my half-understanding of arraylists, now that I've finished the chapter in Head First... The goal is to create 10 'mobs' (monsters) with random health and then be able to access those objects. 1. I have a class called MobInfo which is the attribute template for all monsters, it also includes a prototype of a 'spawner,' ...

6. ListIterator to ArrayList ?    coderanch.com

7. Help with ArrayList    coderanch.com

I purchased the Head First Java And i am into the array list topic already. There's an example named class DotCom where the author used private ArrayList locationCells. I tried the program but it came up with an error. Please tell me what i generated the ff error: setLocations(java.util.ArrayList i DotCome cannot be applied to (int [] ) newGame.setLocations(locations); Here's the ...

8. ArrayList    coderanch.com

i am trying to create an ArrayList and then display it using an Array but theres an exception at runtime import java.util.*; class ArrayListDemo { public static void main(String args[]) { ArrayList a1 =new ArrayList (); System.out.println("Initial size of a1 : " + a1.size() ); //add elements to the array list a1.add("c"); a1.add("a"); a1.add("b"); a1.add("f"); a1.add("n"); a1.add("h"); a1.add(1,"i"); System.out.println("size of a1 ...

9. arraylist problem    coderanch.com

hello there im just starting java and really programming in general, but i am going through the head first java book, and i am having trouble with one of the exercises, i have spent at least an hour typing and retyping this code and checking it against the book, but i cannot find whats causing the error, this is the exact ...

10. Filling an ArrayList    coderanch.com

If you are in Java 5 or Java 6 you can dispense with the BufferedReader by using a java.util.Scanner. But beware: a Scanner takes a delimiter to separate the input into tokens, again by default whitespace. Please avoid StringTokenizer, which is described in the API documentation as legacy software. Suggest: find the Scanner class, pass the File to its constructor, find ...

11. the worlds worst attempt at making ArrayList kind of class, from scratch    coderanch.com

Hi, there is the following class in the book HeadFirstJava. Please see the code comment. How would look a good one? Thank you. /*Building our own Dog-specific list (Perhaps the worlds worst attempt at making our own ArrayList kind of class, from scratch.)*/ public class MyDogList { private Dog [] dogs = new Dog[5]; private int nextIndex = 0; public void ...

12. In the API definition Of ArrayList what does E mean    coderanch.com

E represents an Element, which could be any class. For example, if you're building an array list of Integers then you'd initialize it as - ArrayList list = new ArrayList(); You replace "Integer" with the class that the list is of. ensureCapacity is used to ensure that the list has enough capacity to take in the new elements. It's called internally ...

13. how to get the oldest timestamp record in an array list    coderanch.com

Hi, I have an arraylist. now i want to get the record with the oldest timestamp from all the records present in the arraylist. example: arraylist[] record1 : Thu Oct 09 20:51:03 GMT+05:30 2008 record2: Fri Oct 09 20:51:03 GMT+05:30 2009 record3: Thu Oct 10 20:51:03 GMT+05:30 2008 record4: Thu Dec 09 20:51:03 GMT+05:30 2006 The required output should be record4:Thu ...

14. final ArrayList    coderanch.com

15. about ArrayList    coderanch.com

16. ArrayList    coderanch.com

17. ArrayList Use Question    coderanch.com

import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String[] args) { System.out.println(" Please enter test scores that range form 0 to 100 : ") ; System.out.println(" To compute enter 'Y' or 'y' "); System.out.println("\n"); Scanner in = new Scanner(System.in); double testScore = 0; String choice = "n"; while (choice.equalsIgnoreCase("n")) { System.out.print(" Enter score: ") ; testScore = in.nextDouble(); ...

18. ArrayList error    coderanch.com

import static java.lang.System.out; import java.util.*; public class test_list { public static void main (String[] args) throws Exception { List br; test_list tl = new test_list(); br = tl.getBrands("yellow"); } public List getBrands(String color) throws Exception { try { List brands = new ArrayList(); if (color.equals("yellow")) { brands.add("green"); brands.add("magenta"); } else { brands.add("light brown"); brands.add("light red"); } } catch (Exception e) {} ...

19. Error declaring an ArrayList    coderanch.com

20. ArrayList    coderanch.com

21. ArrayList    coderanch.com

22. Working with an ArrayList    coderanch.com

I need some help. Could some one please help me. Create a Book class that stores book information. Your book class will store book title, author's first name, author's last name, book ISBN-10 number, and publisher, and price. Create a test application that creates several objects of type book class and add each book to an arraylist. Your test application should ...

23. Three Dimensional ArrayList?    coderanch.com

public static List>> create(int dim1, int dim2, int dim3) { List>> list1 = new ArrayList>>(dim1); for (int i = 0; i < dim1; i++) { List> list2 = new ArrayList>(dim2); for (int j = 0; j < dim2; j++) { List list3 = new ArrayList(dim3); for (int k = 0; k < dim3; k++) { list3.add(null); } list2.add(list3); } list1.add(list2); ...

24. ArrayList    coderanch.com

hi, I am having the Arraylist it is having the values(10,11,12,14,15,16) it's series of element but 13 is missing if that arraylist is not in series i need to quit. this is working fine but the first index of the arraylist is not coming. i.e 10 always it's coming 11. in my logic please correct me that logic i should have ...

25. ArrayList advice needed    coderanch.com

OKay so i have assignment called mystery calculator, it seems simple enough but im stuck on how to arrange it.. What initially has to be done is that i have 6 'cards' populated with a series of numbers which cant be hardcoded .. what i have so far is import acm.program.*; import java.util.ArrayList; /** * * * @author * @version */ ...

26. Problem with arraylist    coderanch.com

27. Extracting from my ArrayLists    coderanch.com

I have an assignment and it is driving me crazy. I have managed to create 3 class's that set and can get my values required. I can run my main program which takes values from the user and inputs them into ArrayLists for my class'. However when I come to retrieve and compare the information I get array out of bounds ...

28. Calculate the average of an ArrayList    coderanch.com

you have a few options. you could keep a running total of all the values in the array as you insert them. When you want to calculate the average, get the size (the number of elements in the array), then use those for your division. If for some reason you can't keep a running total, you'll have to iterate through your ...

29. Really strange behavior in an ArrayList    coderanch.com

I am making a small program for one of my CS classes that basically demonstrates mastery of java and programming and such. I have been programming for slightly over a decade, so I assumed that as long as I read the manual I would do fine. This program lets the user create shapes on a board, drag them around, and resize ...

30. arraylist in java    coderanch.com

hello sir, I have hashtable consist of 5 key with their corresponding pair values in the form of arraylist. My problem is i want to get common elements between two arraylists. that is common elements between 1 and 2 , common elements between 1,3 , common elements between 1and 4 , common elements between 1and 5. how can do this is. ...

32. arraylist    coderanch.com

hello sir, i used object[][] el=new object[10][10]; to store arraylist in the form of matrix. and i got the output [1, 3] null null null null null [1, 2] null null null null null [2] null null null null null [] null null null null null [1, 3] my problem is : [1,3] is in the position el[1][1] , [1,2] is ...

33. External method calls in an ArrayList    coderanch.com

Hey, I'm doing my work for uni, which is just an ongoing project which we add to each week. This week we have to change one of the arrays to an ArrayList instead. What I'm having trouble with is calling methods with the ArrayList Object. Anyway I'll post the code which may explain it a little better. Line 69 on is ...

34. 2d ArrayList help !!    coderanch.com

Hi all, I am trying to create a 2D array list which I believe I have done correctly, but when the program runs it just outputs the info from the second set of add(). My current output is: 107 107 I want it to print out the ID of each product, like so: 106 107 Anyone have any ideas? This should ...

35. How data is added in a ArrayList    coderanch.com

36.  help    coderanch.com

It will help if you want to quickly find a JMenuItem based on its name - you won't have to loop through all JMenuItems. Ehm Cody, you do know that more menu items does mean more confusion for users, right? Usually you shouldn't get more than 10 or so menus, each with no more than 20 or so items, and no ...

37. Fetching an ArrayList    coderanch.com

39. "ARRAYLIST BASICS NEEDED"    coderanch.com

40. Java 1.4.x ArrayList problem.    coderanch.com

The follow problem exists in a Java web app. . . I have a form that has a bunch of input boxes, all with the same name.






41. Issue about ArrayList    coderanch.com

Hello, please tell me why it doesnt enter in for loop when user stops inserting and just press enter i.e. null value. import java.util.ArrayList; import java.util.Scanner; import java.util.Collections; public class ArraySorting { public static void main(String[] args) { //... Declare variables. Scanner in = new Scanner(System.in); ArrayList arraylist = new ArrayList ( ) ; //... Read input one word at a ...

42. ArrayList test not working?    coderanch.com

This produces some funny output (ArrayEntry@103c5 or something....). SOMETHING works here.... but I get garbled output when I println the ArrayList. I had it originally as an array.... then switched it because I realized I had no idea how many entries the proverbial end user was going to add. My instinct is there's something wrong with the way I filled the ...

43. ArrayList    coderanch.com

44. Array List Creation Bad Idea    coderanch.com

You don't want to lock yourself into a specific data type. by saying "List arrList =", you can later change the "new ArrayList(); " to ANY object type that implements the List interface. I think this is less of an issue when you are writing your own, small applications. It becomes more of an ordeal when your team is writing part ...

45. Initializing and adding to an ArrayList    coderanch.com

You win for "rules lawyering." IOOBE, not a real word, is easier than writing IndexOutOfBoundsException. Though, I could have cited first, then used the "acronym." I know that an ArrayList is zero-indexed. I did pass the SCJP exam...allow me to bask in my self congratulatory sun...now... What I was trying to say, though I was unclear, is better demo'd in code... ...

46. problem with ArrayList    coderanch.com

47. ArrayList & ListIterator Help    coderanch.com

Okay, so I am not sure exactly what information I need to give, but I will try... I have a program called "QuestionBuilder" that will allow the user to enter several fields for a trivia question and some answers, then hit the 'Next' button. They will also be able to hit the 'Previous' buttons, but the Previous button is disabled unless ...

48. using array list    coderanch.com

49. filling an array list    coderanch.com

i have my array list and i am trying to use my method and the other two array list to make calculations and fill another array list. basically what i am trying to do is take my two array lists, plug them both into my method, and then return a value. i got further instruction on the assignment and realized that ...

50. Begginer problems with ArrayList    coderanch.com

In the future, please UseCodeTags. It's unnecessarily hard to read the code as it is, making it less likely that people will bother to do so. Does it really print nothing? It should print something like "[Varor@3f3789]", which would be the String representation of the List object. If you want to show the individual List elements, then you should iterate over ...

51. Please help with arraylist problem    coderanch.com

Hi Guys, I am new to this forum, and i am new to java. The question is that i have created an imaginary table, and i will take the input column and input row from the user to point to a specific cell within that table. The tric that if the user inputted the same cell, the program wouldn't allow him ...

52. ArrayList what mean?    coderanch.com

53. ArrayList issue    coderanch.com

54. ArrayList Implementation    coderanch.com

Ya I agree with you. The old class - has an array which is a dictionary filled with elements of type (DictEntry) . What I meant by " serve the aim" is : to create a new arrayList object to be used instead of the old array, ( serving as dictionary). Thank you =)

55. arraylists??    coderanch.com

Hiya, Working on vehicle rental system. Go to return a vehicle from a parameter string registration. Task is to change its return date and calculate difference? Can anyone explain how to loop through an array list and change a vehicles rental date to a new date? So far trying... public void returnVehicleByReg(Vehicle car, String reg) { Iterator i = vehiclesOutForRent.iterator(); for(int ...

56. adding to an arraylist from an if conditional?    coderanch.com

public class action implements ActionListener { ArrayList comList=new ArrayList(); public void addCommand(char x) { comList.add(x);//NPE } public ArrayList getList() { return comList; } public void actionPerformed(ActionEvent e) { if(e.getSource()==up) { JOptionPane.showMessageDialog(null,"up"); addCommand('U'); } This is for a maze game with a gui. up is a button on the gui, and there are also buttons for down, left, right, etc. I need ...

57. ArrayList help needed    coderanch.com

A few things: 1. Please place code inside code tags. It makes it much easier to read. You can do this when writing your post using the "Code" button above the main entry box. 2. We have a policy here to use a real sounding name. If your name really is Megan Fox that is fine, but odds are a sheriff ...

58. ArrayList    coderanch.com

59. get hashmapvalues of arraylist    coderanch.com

iam getting result set as hashmap and storing them in a an arraylist and returning that arraylist to the method callers. When i applied iterator on that returned arraylist with itr.hasnext () iam getting key and values also BUT for some reasons i just want to get only values from arraylist could some one suggest me please and if some one ...

61. ArrayList Instance Creation    coderanch.com

There really isn't that much of a difference between the two reference declarations shown. Since both mention ArrayList by name, both are tightly coupled to that implementation. In practice, as long as you don't call any ArrayList specific methods on the list (and really, why would you?) they're both just as painless to refactor to a different list implementation. The first ...

62. Doubts regarding ArrayLists    coderanch.com

When I click on run in eclipse I am gettting "A java exception error occured message" after clicking on "ok" in that message, I am getting another message saying "Error:JNi error has occured, please check your installation or try again later". But I can restart the eclipse and run other programs, but when I run this program, I get the above ...

63. Fastest Way to traverse an ArrayList    coderanch.com

Actually, the proper answer is "it depends". For ArrayList, the fastest way would be to use size() and get(int). For LinkedList, the fastest way would be to use an Iterator. The difference can be found out by checking if the List implements RandomAccess: if (list instanceof RandomAccess) { for (int i = 0, size = list.size(); i < size; i++) { ...

64. ArrayList throws    coderanch.com

65. ArrayList:    coderanch.com

Jama, Welcome to Javaranch As Ed Ward has mentioned it depends on the version of Java you are using. If you are using Java 5.0 or above it willl compile, run and give output as in Java 5.0 (or above) as Autoboxing/Unboxing feature is available in it. But if you are using previous versions of Java it supports only Colloections of ...

66. ArrayList problem. Head First Java, p. 138 - 139    coderanch.com

We're supposed to use the ArrayList to get around a problem with Arrays. This is in the simple version of the game. Just one row of numbers. Enter a number between 0 and 6 and "hit" a dotCom that occupies three of those cells, hit all three and you get a "kill" and game is over. The problem; if the dotCom ...

67. Problem with ArrayList    coderanch.com

Hello, I dont know if this is the right place to ask this question, but if you can help me out with this i would be grateful... I was trying to read from an xml file and save node contents into an ArrayList, these contents are names of files which i need to use later after .. the problem is: whenever ...

68. How to restrict the add in an ArrayList    coderanch.com

buntha Choudhary wrote:Hi Mohammad , thanks for the suggestion but I do want to use the list outside the class as well . Only I want to restrict the add method. So if I am getting your point ,private won't give me the desired result. I meant- You make the List private, and provide a public add/get method where you can ...

69. Need help creating arraylist of stacks    coderanch.com

70. Empty ArrayList    coderanch.com

This is an ArrayList, not an Array. While you have defined the initial capacity, it is still empty until you put something in it. The initial capacity is used for determining the supported size behind the scenes so that you can reduce the time spent resizing the data structure behind the scenes if you already know (or have a good idea ...

71. ArrayList    coderanch.com

hi experts, consider this coding a) List data = new ArrayList(); b) data.add(new Integer(1)); c) data.add(1); d) System.out.println(data); the result is [ 1,1 ] i know that ArrayList / List holds only object type, not the primitives type. then line c should be error know? then how it executes fine? please any one throw light! thanks in advance.

72. basic question about ArrayList    coderanch.com

73. Arraylist Issue    coderanch.com

74. Understanding 2D ArrayLists    coderanch.com

My background is over 50 years of programming 3rd generation languages so much of what I code is colored by that experience. Now I am coding java & many things I don't understand. Can someone help me to understand the following problem. I need a 2-d array, array, of !0 rows by 4 columns. The members of the array are booleans ...

75. Why is the below code giving error related to ArrayList<>    coderanch.com

The parameter of takeList isn't named. That's the reason you're getting this error. If you fix that, you'll get another error though. Dog extends Animal but ArrayList does not extend ArrayList. The difference is that an ArrayList can store Cat objects whereas an ArrayList cannot. That's why generics have wildcards; ArrayList does extend ArrayList. But you can't add anything ...

76. GregorianCalendar to ArrayList    coderanch.com

Hey guys. I've got a small bit of code i'm having trouble with. Here's the idea. The user has a JTextField to put a date into. Once they put in the date, it is 1) Checked to make sure it is actually a date 2) Converted into type gregordianCalendar 3) Stored in an ArrayList for the future part of the program ...

77. ArrayList    coderanch.com

import java.util.ArrayList; public class AraryListDemo { public static void main(String[] args) { ArrayList al = new ArrayList(); System.out.print("Initial size of al : " + al.size()); System.out.print("\n"); //add.elements to the array list al.add("C"); al.add("A"); al.add("E"); al.add("B"); al.add("D"); al.add("F"); al.add(1,"A2");//inserts objects "A2" into array at index 1 System.out.print("size of al after additions " + al.size()); System.out.print("\n"); //display the array list System.out.print("contents of al: ...

78. Array List    coderanch.com

79. Generating distribution from an ArrayList    coderanch.com

Hi all, I have a sorted ArrayList of values. I would like to get the distribution of the values. For example: - Say I have 500 values, ranging from 1-100. - I want to break them up into groups, say 10 groups: values 1-10, 11-20, 21-30, etc... - I want the counts of each of the 500 values that fall into ...

80. arraylist    coderanch.com

82. slowness in the Arraylist adding    coderanch.com

Hi , i'm facing a performance issue with the ArrayList specificly in adding to it , briefly i'm reading about 10000 to 40000 records from the DB and putting them in the some ArrayLists to make some processing on them later , i thought may be the delay from the query itself i tried it outside my code it was very ...

83. ArrayList Problems, Help needed    coderanch.com

Help needed please. The Arraylist, det, below behaves as if I am adding the same object again and again. Clearly within the while loop I am creating a new instance of the Detail class on each iteration. Using this instance I am able to set the various properties. However, the code that follows the while loop i.e. the for..each give me ...

84. Exporting ArrayList of beans to xls, csv, txt, dbf    coderanch.com

Hello, I am doing a Flex 4, Blazeds, Spring, myBatis, jasperReports application project. I am able to export jasperReport print object in many formats out of Box. Now a new requirement has popped up. User needs the base data used for report in xls, dbf, csv, txt formats which comes from database table through myBatis in the form of Arraylist of ...

85. ArrayList    coderanch.com

86. Can't add to ArrayList within switch statement?    coderanch.com

I'm having trouble inserting objects to an ArrayList within a switch statement. Before entering the switch, the add function works fine. Here's the code: import java.util.*; public class AppointmentBook { public static class Appointment { int timeS = 0, timeE = 0, date = 0; String description = new String(""); public Appointment(String desc, int day, int start, int end) { timeS ...

88. Manipulations with array list.    coderanch.com

Hello everyone. I need to write a code fragment to determine the number of the elements held in Array List "list" which are greater than half the maximum value. Here I have found maximum value: ArrayList list = new ArrayList(); list.add(new Integer("3")); list.add(new Integer("1")); list.add(new Integer("34")); list.add(new Integer("32")); list.add(new Integer("56")); Object obj = Collections.max(list); System.out.println(obj); Any ideas?

89. Arraylist insights    coderanch.com

java.util Class ArrayList 1. This class is "unsynchronized" mean in the Java context? Source: http://download.oracle.com/javase/6/docs/api. 2. "public int hashCode() This method returns the hash code value for the object on which this method is invoked. This method returns the hash code value as an integer and is supported for the benefit of hashing based collection classes such as Hashtable, HashMap, HashSet ...

90. ArrayList issues?    coderanch.com

java.util.ArrayList "You can pass a typed array list to the update method without any casts. ArrayList staff = ...; employeeDB.update(staff); The staff object is simply passed to the update method. Even though you get no error or warning from the compiler, this call is not completely safe. The update method might add elements into the array list that are not of ...

91. ArrayList?    coderanch.com

... ArrayList magicNumbersList = new ArrayList(); for (int x = 0; x < 10; x++) { for (int y = 0; y < 10; y++) { Integer anInteger = Integer.valueOf(magicNumbers[x][y]); magicNumbersList.add(anInteger); if (y == 9) { System.out.println(); } } } for (int i = 0; i < magicNumbersList.size(); i++) { System.out.println(magicNumbersList.get(i)); } ...

92. basic array-list method help    coderanch.com

Hello all and thanks for the forum. I am trying to understand some basics for a class I am taking. I need to add a boolean method contains to my class called IntList which already has a bunch of other methods in it I created. All the method needs to do is return true if the parameter I am adding is ...

93. Quick ArrayList Question    coderanch.com

94. Returning ArrayList from Method    coderanch.com

public ArrayList getScoreValues(String pShootType) { shootType = pShootType; scoreButtonValuesArray = new ArrayList(); try { Connection conn = DatabaseScoreDisplay.getConnection(); Statement st = conn.createStatement(); ResultSet rec = st.executeQuery( "SELECT * FROM SCORE_VALUES WHERE " + shootType + " = 'Y'"); while(rec.next()) { ScoreButtonValues buttonValues = new ScoreButtonValues( rec.getInt("ARROW_VALUE"), rec.getString("ARROW_DISPLAY_NAME"), rec.getString("ARROW_COLOUR_BACKGROUND"), rec.getString("ARROW_COLOUR_FOREGROUND") ); scoreButtonValuesArray.add(buttonValues); } } catch(Exception e) { System.out.println("*** Error : "+e.toString()); System.out.println("*** ...

95. Array List    coderanch.com

You will need to build the data. What the above folks are suggesting is as follows... define a map with a String as the key, and an Int as the value. read through your array, one at a time. For each element, check the map to see if the current element exists as a key If not, add it in with ...

96. ArrayListS in an ArrayList that consists of ArrayListS behave like they are the same instance    coderanch.com

I am turkish and my variable names are turkish. i hope it won't be a problem. here is the code: ArrayList> denemeKombinasyonuCumleKelimesiListesiListesi=new ArrayList>(); int i=0,j=0; ArrayList geciciListe; while(matris[0][j]!=-1){ geciciListe=new ArrayList(); i=0; while(i

97. ArrayList    coderanch.com

S, it would have helped if you had pointed out where you read this. After some searching, I assume you're talking about the quote from the ArrayList API: The size, isEmpty, get, set, iterator, and listIterator operations run in constant time. The add operation runs in amortized constant time, that is, adding n elements requires O(n) time. All of the other ...

98. ArrayList problem ...    coderanch.com

s begri wrote:Below is my cod : class Animal extends ArrayList { } but when I modified and add the public static final long serialVersionUID = 0; that warn vanishes . Can anybody explain why this is happening ? better to modify the public access modifier to private. infact, ArrayList implements Serializable interface, so your Animal is a Serializable. ...

99. Query on arraylist    coderanch.com

Hi All, If I have an arraylist of strings, and the content of this arraylist is essentially as follows: [divya, divya1, divya2, divyachan, divyachan1] while inserting a new value into the list, e.g. if i want to insert "divya" i need to loop through the list check if it already exists, if yes, i need to see if there is already ...

100. Filtering an ArrayList    coderanch.com

// define the Map here Map map = new HashMap(); (){ String name = // get the name of the current item... Integer value = // get the value of the current item... Integer oldValue = map.get(name); // You may use if-else instead of ternary operator here. map.put(name, (value==null)? value : ((oldValue < value) ? value: oldValue)); ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.