ArrayList 7 « 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 7 

1. Problem with ArrayList    forums.oracle.com

2. MetaClass and ArrayLists    forums.oracle.com

/* This part of the code finds methods. It utilizes a int called stack to do this. It starts at the beginning of the line and looks first for a ". If one is found, the line is skipped. If it finds a modifier, it then looks for either a second modifier or a primitive data type. If one of those ...

3. arraylist.add() problem    forums.oracle.com

The constructor is either going to return an element, or throw an exception. So data would get into the array, unless the add() method is not being invoked. It's not being invoked because an exception is being thrown, or because you're not actually invoking it at all. Another possibility: another part of your program is overwriting the customers list with a ...

4. Resetting an array list    forums.oracle.com

I have an ArrayList that keeps a running total on a per game basis. When the user resets the game I want to clear that list for the next game but cannot figure out how. I tried setting the list equal to null but the next run raises a nullPointerException. Any suggestions?

5. Arraylist class methods    forums.oracle.com

6. I/O and ArrayList Problem    forums.oracle.com

So I am new here, I try to not use resources like this to complete my programs, but I am stumped and cannot seem to find a solution to my problem. Basically I have a program that is controlled by switch statements and it creats an Array to store data. You can add, search, etc. You can also save the array ...

7. can you have multidimensional arrayLists?    forums.oracle.com

8. are multidimnsional arraylists possible    forums.oracle.com

Good day to you all, I am just wondering if multidimensional arraylists are allowed in java. I have a model with different nodes connected together by labelled lines. what i want to do is be able to retrieve what worlds are connected by which lines. i know it is possible with multidimensional arrays, because both the rows and the columns can ...

9. ArrayList    forums.oracle.com

10. how do i use ArrayList with multiple collumns?    forums.oracle.com

Is a list of lists better than an arraylist? or am i just missing it. Does it work in the same way with going line by line interator? Do you use a list to define the arraylist? I am going to be storing large amounts of data, like 80,000 records from txt file, LoL, any problems. I havent used a list ...

12. how to use ArrayList    forums.oracle.com

13. Creating arraylists during run-time.    forums.oracle.com

I'm writing a client/server application and want to create arrays during run time. I know this is easily done. But what I want to do is name the lists "clientX" where X is the numerical id of the connected client. For example, 20 clients connect to the server. I want the server to create an ArrayList for each client upon connection ...

14. ArrayList problem    forums.oracle.com

} while (!front.equalsIgnoreCase("0")); System.out.println("Do you want to save the deck? 1- yes"); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); try { dummy= br.readLine(); } catch (IOException ioe) { System.out.println("IO error trying to read entry!"); System.exit(1); } iopt=Integer.valueOf(dummy).intValue(); if (iopt==1) newdeck.savedeck(newdeck); return newdeck; } public int savedeck(Deck decktosave){ FileOutputStream out; // declare a file output object PrintStream p; // declare a print stream ...

15. Help With ArrayList    forums.oracle.com

17. type parameter in ArrayList    forums.oracle.com

18. ArrayList - JDK compatability?    forums.oracle.com

Hi folks I am trying to initilize & execute a basic ArrayList, when I try to compile it's throwing following error is that because of the JDK version? %> :Class ArrayList not found in type declaration. private ArrayList Observer; Right now I am using JDK1.1.8 is there any latest version available... Thanks LORD

19. Array list    forums.oracle.com

Just don't add more than 10 customers. If you want to enforce that programatically, then try extending ArrayList (I think it's final, but can't check right now) and override the add to impose your facile limitation... If that doesn't work wrap ArrayList in a DodgyArrayList... make sure it implements all the same interfaces as ArrayList. Yuk! Failing that refer to option ...

20. ArrayList problem ....    forums.oracle.com

21. Array List    forums.oracle.com

Hi, I am new to Java.I want a solution for my problem. Scenario for my problem is: My project is in Healthcare.I want to "add multiple dependents" thru a jsp. A dependent has various fields such as Name,Age,Address,*** etc. Plz tell me how to get these values from jsp to servlet so that I can update the database for the given ...

22. ArrayList help    forums.oracle.com

24. ArrayLists    forums.oracle.com

Where are the null errors coming from? the buildings? the rooms? Are you initializing your Room objects before putting them in the arraylist? If not, then there is your problem. Consider initializing the object in the buildings.add method by creating an anonymous object. If you did that, you would have to add an instance field to Room for the roomName, but ...

25. ArrayList manipulation and Comparators    forums.oracle.com

The Person class does not have a meaningful toString() method. You should override the toString() method to provide meaningful data associated with the object. To have data in a certain order requires you to sort it in some manner or another. I'm off to another boring meeting but I'm sure one of my esteemed colleagues will continue for me. Good luck ...

26. Making buttons for an ArrayList    forums.oracle.com

I am in a hurry as this program has to be handed in tomorrow so quick replys would be helpful. I dont know how to make buttons in my GUI for an ArrayList and have it respond individualy with the name of the button i.e. i want to make it so that when you click on the drill button it will ...

27. working with arraylist for first time, not adding up!    forums.oracle.com

/** The Hotel will have an addRoom method that will create each room with the required information: room number, bed type, smoking/non-smoking, and the room rate. Create at least 5 rooms with different characteristics. Each room will also have a boolean field called occupied attribute that will be set to false when the room is created.**/

28. Using a MergeSort with an Array List    forums.oracle.com

29. Problem with ArrayList method    forums.oracle.com

30. ArrayList other classes    forums.oracle.com

} /** * An example of a method - replace this comment with your own * * @param y a sample parameter for a method * @return the sum of x and y */ public String searchByAuthor(String author) { for(String book : books) { if(book.getAuthor().equals(author)) { return book; } } return null; } public void enterBook(String book) { //books.add(newbook); books.add(book); // ...

31. ArrayList inside ArrayList    forums.oracle.com

32. Simple arraylist problem    forums.oracle.com

Well if you want to add a student to the arraylist then you need to create a new student object, and then fill in the parameters which will take some considerable time, esp if you have over 100 students... creating the students within the populate method should save a lot of time... in theory. He states that we only need to ...

33. arraylist in abstract class?    forums.oracle.com

i just want to ask a simple question.....is it possible to create an arraylist in an abstract class? because there is no constructor in an abstract class and i normally create an arraylist in constructor. say if it is possible, will i be able to add or remove an element from the arraylist when i add these methods in a normal ...

34. ArrayList question    forums.oracle.com

All that an ArrayList holds is a bunch of references to objects not the object itself. So what you are doing is creating a Vehicle object and setting some values ie Honda. Then a reference to that object is added to the List. You then change the make of that SAME object to Acura and add the SAME reference to the ...

35. ArrayList    forums.oracle.com

hey i have a class which stores information about a person i would like to have an add method in an array list in another class this is the idea i have about how to implement this which i found in a tutorial ArrayList people = new ArrayList(); people.add(new person (???)); i would appreciate it if anyone could tell me if ...

36. ArrayList    forums.oracle.com

37. I need ungrowable ArrayList    forums.oracle.com

38. question about hashSets and Arraylist    forums.oracle.com

i was learning collection in java. i know about arraylist but never knew about HashSet so i started programming just a basic program adding deleting, sorting and searching. but i dont find any difference in the output whether i do with Arraylist or use HashSet its The same identicial. am i right?

39. Error with ArrayList - I think.    forums.oracle.com

Bear in mind that you can turn any collection into a regular array of Object with the toArray() method This is extremely useful for iterating over all members of the array with the side-effect that the original collection can safely be modified (for example by another thread) while you're iterating. For small collections it is also fairly efficient.

40. adding to arrayList    forums.oracle.com

In your for loop you are trying to add an object to the list you are looping through. You cannot do this, you should set some boolean variable if the book is found in the list, then after the for loop add your book if it was not found. And you'd probably be better off using .equals() instead of .contains() to ...

41. Why wont this add to my ArrayList???    forums.oracle.com

42. can not add a member to arraylist    forums.oracle.com

System.out.println("Sorry, the ID already exists in the libaray"); } else { members.add(newMember); The issue is that im not able to add the new member to the arraylist if the new member's ID is not the same as the other Member IDs in the arraylist. When i check the size of the arraylist with size.(), it just returns the value 0. Not ...

43. Another issue with arraylist, kinda weird    forums.oracle.com

Thanks Bernie, you made that code work. However, I got another issue. That looks like arraylist.add(), replaces all entries rather than adds to the end of the list. I cannot find what is wrong with that. But you or some other expert will probably notice what is wrong. the code, that is below, prints : 4 4 4 4 4 import ...

44. array list    forums.oracle.com

Remember when I asked you if you had any particular rationals in mind? I assume you are talking about the set of rational numbers Q (any number that can be represented by p/q, p & q integers and q != 0). There is no "rational" type or primitive in standard java. You can make that ArrayList be any type you want, ...

45. need help plzz in arrayList + circle class    forums.oracle.com

this.c = c; this.r = r; } public Point getC() { return c; } public void setC(Point c) { this.c = c; } public double getR() { return r; } public void setR(double r) { this.r = r; } public String toString(){ return "c="+ c.toString()+"r="+r; } ///////////////////////// public boolean isInside(Point testPoint ){

46. playlist with arraylist    forums.oracle.com

47. arraylist problem.    forums.oracle.com

48. help on ArrayLists    forums.oracle.com

Hi, im pretty new to Java, and am having trouble with extending my use of ArrayLists. I have a piece of code to create an Array List, and I add objects to it in my main method using .add( ). Instead of having code creating and manipulating an ArrayList in my main method, I want to create a class called PersonList ...

49. array list help    forums.oracle.com

50. ArrayList problems    forums.oracle.com

I'm new to Java, and I'm having trouble with ArrayLists. I'm working through the exercised in a book called "Objects First with Java". I have an array of type 'Lots' called 'lots'. I want to run go through the array, and add any unsold lots to a new array, then return that array. In another method, I want to loop over ...

51. ArrayList    forums.oracle.com

52. ArrayList Problem    forums.oracle.com

Hi I am now having two arrayList for my picture uploading software. 1 ArrayList is actually to maintain the File array. So that I can actaully add or remove files frm arrayList 2nd ArrayList is for the JLabel which display the thumbnail of the images which user can select to clear or upload the files. And I map these two arrayList ...

53. ArrayList    forums.oracle.com

I have created 3 arrayLists, which have data read into them from a txt file. I now want to search them, using I presume an Iterator. The search would be for example, get the make of a car with the following registration no. I have been battling with working this out, but to no avail. SO far I have got... /**getMake ...

54. Two arraylists    forums.oracle.com

I didn't look really closely at your union logic - but it makes me uneasy. You could use a Set and add everything in both A and B to it. Then you can return new ArrayList(set). Also, I wouldn't use '==' the way you are. Autoboxing will probably save you - but I'd suggest using .equals() instead, to make it clear ...

55. Help with ArrayLists    forums.oracle.com

56. ArrayList to hold obects    forums.oracle.com

I am using an ArrayList to hold 5 distinct objects. These 5 objects are instances of 5 different classes inherited from a common parent.. The parent class has a method called foo(), which all the 5 sub-classes over-ride. After adding the 5 objects to an arraylist, I am trying to call the method foo() using for (int i=0;i <5;i++) { ol.get.foo(); ...

57. Occurencs in ArrayList    forums.oracle.com

58. Unable to execute ArrayList member's method    forums.oracle.com

59. ArrayList in Java on UNIX Platform    forums.oracle.com

60. Help please!! Arraylist Search/Count    forums.oracle.com

All of the action takes place in the DateCount class. Take a look at the countDates() method in detail. It is passed an array of String(s) where each element is a 'date', I used this just for testing and I am sure that once you get the idea, you can modify it so that the technique works for you. Anyway, all ...

61. Getting an ArrayList    forums.oracle.com

62. Using arrayList.set    forums.oracle.com

63. adding tokens into a arraylist    forums.oracle.com

Hi friends,i tried this ,but iam facing NULL POINTER EXCEPTION.Iam new to java pls help me and also i need to keep all these tokens into a arraylist. try { f = new File("C: Documents and Settings\\sumave\\Desktop textfile.txt"); fis = new FileInputStream(f); BufferedReader d = new BufferedReader(new InputStreamReader(fis)); while(!(s = d.readLine()).equals("")) { StringTokenizer st = new StringTokenizer(s, " "); while(st.hasMoreTokens()) { ...

64. How to create model from arrayList of beans.    forums.oracle.com

65. ArrayList Problem    forums.oracle.com

66. Passing/returning ArrayLists    forums.oracle.com

67. ArrayList problem    forums.oracle.com

Those are both great answers, thanks all. I think I am going to go the Map route, it does seem to be made specifically for this kind of thing. I have taken the first 2 Java courses from Sun, but they don't mention the Map object in the coursework. Thanks for the help, all!

68. ArrayList retrieval    forums.oracle.com

I have an object (a) of an (Account) class. This object (a) contains two Strings and two ints. I have no problem storing this object (a) in the ArrayList, which I have called (accounts). However, I don't understand how to simply output the contents of my object (a) from the accounts ArrayList. By that, I mean I flat out don't understand ...

69. ArrayList    forums.oracle.com

70. working with ArrayList and classes    forums.oracle.com

init: deps-jar: Compiling 1 source file to C:\Java\StudentRegistration\build\classes C:\Java\StudentRegistration\src\StudentRegistration.java:127: cannot find symbol symbol : method compareto(java.lang.String) location: class java.lang.String if (s.getId().compareto(id)) C:\Java\StudentRegistration\src\StudentRegistration.java:145: non-static variable this cannot be referenced from a static context Admissions adm = new Admissions(); C:\Java\StudentRegistration\src\StudentRegistration.java:146: non-static variable this cannot be referenced from a static context Admissions drop = new Admissions(); C:\Java\StudentRegistration\src\StudentRegistration.java:159: non-static variable this cannot be referenced from ...

72. ArrayList    forums.oracle.com

73. multidimensional arrayList    forums.oracle.com

<%=days%><%=empId%> <% pointer ++; } else { %> <%=days%> <% } }//close compareTo } //close for i=0 <% showCal.add(Calendar.DAY_OF_MONTH, 1); %> } When I was only showing 1 person's data, the ptoDays.getPtoDate().compareTo worked, but now that info is inside another arrayList, and that call doesn't work. I need something like empPriorPto.ptoDays.getPtoDate().compareTo, but can't find anything.. I know I need ...

74. manipilate arraylist in javascript    forums.oracle.com

Hi Every one, On the time of form loading i'm getting one arraylist from that i have itreate the bean values in jsp page using scriptlate tag (it is table format), If the user select delete record then the particular recrd will be delete from the table and also from the arraylist. It is possible can any one suggest me how ...

75. Is it a better practice to create an ArrayList at class level?    forums.oracle.com

Bad suggestion. Variables should be declared in the scope in which they are used. Also bad reasoning. It needn't bother the programmer that garbage collection isn't guaranteed to run whenever a variable goes out of scope. It's sufficient that it is guaranteed to run before the program throws a OutOfMemoryError. That said, parts of the JDK instantiate an object as a ...

76. arraycopy() VS ArrayList    forums.oracle.com

77. ArrayList going out of scope?    forums.oracle.com

Hi, I have a JSP running on a portal that doesn't give me much in the way of debugging information, however I believe that I have a scope problem with the following code, where I declare and initialise an ArrayList outside a for loop, but once used in the for loop, it seems to go out of scope and cannot be ...

78. Need advice for game, using ArrayList?    forums.oracle.com

Hello to the Oracle forums. Was hoping I could ask for some help. I'm currently carrying out an assignment for a university class. We've been working on java-based 2D and 3D games, and the final assignment is to make a 2D game and a basic 3D rendition of the 2D game. We've been given a modified GameCore from the Developing Games ...

79. Arraylist    forums.oracle.com

Have you ever read an explanation of scope, life time, and visibility? You have to declare the variables that you want to use in a scope that will be visible during execution and will result in the variable having the appropriate life time you desire: In your case you need that variable declared outside your class, in a common scope. Declare ...

81. arraylist    forums.oracle.com

Regardless if index is 1 or 100000, you're trying to add something to an array list at a spot that doesn't exist. Go to the ArrayList API and see why the error is being thrown. If you really want to store TruckDrivers in a collection based on their ID, consider using a HashMap (as I already stated in my other post ...

82. About the java.util.ArrayList    forums.oracle.com

83. ArrayList get    forums.oracle.com

Hi, I hope some one can help me, I've been through the first 20 answers on google but cant understand where I'm going wrong. I have an arrayList called deck, which contains Card's which have enum values of cardValue and cardType. I am trying to print the top card. System.out.println((Card)deck.get(0)); It keeps just printing the object ref. Thanks,

84. paintComponent and ArrayList    forums.oracle.com

85. ArrayList help- My java assignment    forums.oracle.com

But when your assignment is due has nothing to do with the problem. Does it? I and many others do not care when your assignment is due. It does not guarantee you an answer any sooner than anyone else. In fact some refuse to help so it actually hinders your chances of getting help. In future only include information that is ...

86. Help with array list    forums.oracle.com

Do you mean it prints out the highscore list, but only with the Player on it that played last? If so, chances are that you reinitiate it somewhere in your code. Search for uses of "scores", maybe its that easy. Edit: I believe the process is something like this: - set scores = new ArrayList - start Game - player ends ...

87. arrayList    forums.oracle.com

If a new object has to be created every time a player starts playing, whether that is the first time since the program has been run or the fifth time, how can a new object be created automatically and be given a name? I wouldn't know how many games will be played.

88. equals for ArrayList.lastIndexOf()    forums.oracle.com

I have a class tile public class tile implements Cloneable { int value; // 1-13 and 0 for joker int color; // 0-3 for Red Yellow Blue Black int location; // 0 for Rack, N for group on board int newGroup; ... I have an ArrayList of tiles but the lastIndexOf method is returning -1. In tile I added public boolean ...

89. Help with arrayList    forums.oracle.com

Implode wrote: what if an object has multiple data types? This is a bad idea. It makes no sense to have a list containing a Spoon, a Clock, a Chair, a Caterpillar etc. On the other hand if you have Sedan, StationWagon, SUV etc classes then you should have a parent class they all extend, Car. Then you can make your ...

90. please help creating a group of my class - should I use ArrayList?    forums.oracle.com

****. This seemed like the most intuitive technique to do what I wanted to do. My ultimate need is this: I need to create a bunch of myClass objects (WUDependent's) that eventually I want to loop through using a for-loop that would let me perform a function on each one. Can you suggest a better technique? Thanks! Edited by: lkb3 on ...

91. please clarify about Arraylist    forums.oracle.com

[>>headdesk<<|http://www.geocities.com/darrylbu/images/headdesk.gif] Why are you checking whether or not the ArrayList itself is a String of a single character (which is something entirely different from an empty string, of course, but that is beside the point). It is, of course, not the same. It is not even a String, it is an ArrayList.

92. ArrayList's with custom types    forums.oracle.com

Ok so lets say i have a bank class and an account class. Inside the bank class I have an ArrayList accs. Now they account class has many of its own methods and stores a lot of data... Lets say the most essential part is the AccountNumber long. Well if i run accs.remove(account) it can never removes the account from the ...

93. help with Arraylist    forums.oracle.com

94. computeAverage(ArrayList a)    forums.oracle.com

95. arraylist with class methods, really confused    forums.oracle.com

97. Arraylist add    forums.oracle.com

98. Adding user input to an ArrayList    forums.oracle.com

Basically, I have to write a program where: -I prompt the user for the names of all the courses he/she completed last year. -I prompt the user for the grades acheived in all the courses. -Then show the user all the subjects which he/she scored >93% (high achievement award marks) and <70% (needs improvement) I started off, but then got stuck ...

99. ArrayList and imports    forums.oracle.com

Again, exactly what problem are you having? All you've really said is "it doesn't work," which contains no information. Don't bother posting the JDBC stuff here, as that's no relevant if your problem relates to processing a text file. Show the code that you tried and describe clearly, precisely, and thoroughly what exact problem you're having with it.

100. array list?    forums.oracle.com

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.