arraylist

Is it possible to patch a memory leak using a try-catch statement?

if(pCoeff.size()>thisCoeff.size()){ difference=pCoeff.size()-thisCoeff.size(); for(int i=thisCoeff.size(); i<thisCoeff.size()+difference;i++){ thisCoeff.add(i, new Double(0.0)); //this line throws errors } } I've isolated this portion of my program as being the cause of memory leak, is it...

Java ArrayList: Merging ArrayLists within ArrayLists to create one ArrayList :O

Hello again, I've looked around but I can't seem to find an API call that does the following: I need to merge all ArrayLists in an ArrayList to form one ArrayList with all the elements from all the sub-ArrayLists, if that makes sense. Here's an example: {"It's", "a", {"small", "world, "after"}, {"all"}} becomes {"It's", "a", "small", "...

Why are most of the examples using ArrayList

Developing Java, you have always learned that its best to create an ArrayList by using the List interface as the type for the variable the list is stored in. Like this List<String> myList = new ArrayList<String>(); However, by looking at a lot of the android examples that is included in the bundle, they have created the list by using ...

Creating an Arraylist of Objects

So, now I've figured out how to make multiple of the same object correctly, I need to know how to make an array of them, changing depending on how many are needed, because it is pretty much an object, that stores 3 numbers. How can I Create an arraylist that is of different objects, because I'm going to have the numbers inside them diffe...

Keeping enums sorted in an arraylist?

Say I had a an enum called Planets that contained VENUS, EARTH, and MARS. I will have a lot of array lists that will hold at most one of each type. I want to keep each array list sorted at all times in order from VENUS, EARTH, and MARS. Would I need to use a comparator for this? Is there a way to keep them sorted automatically after an ...

How do I remove sequential elements from a Java ArrayList?

I'm a relatively new Java programmer and I'm having difficuly removing more than one element from an ArrayList. Ideally I'd like to do something like this: ArrayList ar1 = new ArrayList(); ar1.add(...) ar1.add(...) ar1.add(...) ar1.add(...) for (int i = 0; i < 2; i++){ ar1.remove(i); } I think iterator might help, but I can't f...

I want to find the strings that repeated more than 1 times

dear all I have an array of strings. Some of The strings are similar (for example, person is similar to twolegperson, animal is similar to animalgold). I want to find the strings that are repeated more than 1 times (here person,animal). Thank you very much faty ...

android parcelable string array

I have ArrayList<String> ids = ArrayList<String>(); What would be the cleanest way to make it Parceleable? Apparently String itself is not parcelable, so Parcel.writeList(ids) is not working. I was thinking to either parcelize ArrayList<Uri> or put array contents into a Bundle. ...

Why does this attempt to output an arrayList object to a JtextArea not work?

ArrayList list_of_employees = new ArrayList(); @Action public void reportAllEmployeesClicked(java.awt.event.ActionEvent evt) { this.outputText.setText(""); int i=0; //JOptionPane.showMessageDialog(null,"test Employee list print"); ListIterator list_ir = list_of_employees.listIterator(); //list_of_employees is of ...

Assigning null to ArrayList items in Java

Hi, I have the following code: static ArrayList<PreparedStatement> alPrepStmts = new ArrayList<PreparedStatement>(); static PreparedStatement m_stmtOne; static PreparedStatement m_stmtTwo; static PreparedStatement m_stmtThree; ... static PreparedStatement m_stmtOneHundred; private static void init() { alPrepStmts.add(m_stmtOne); ...

problems with putStringArrayListExtra() in Android

Hi I want to pass an Arraylist from one activity to another. I use putStringArrayListExtra(), but there shows an error : "The method putStringArrayListExtra(String,ArrayList is undefined for the type bundle." Is there any other method available for passing ArrayList? String test[]=new String[3]; ArrayList<String[]> al=new ArrayList...

How to pass ArrayList using putStringArrayListExtra()

Hi I want to pass an Arraylist from one activity to another. I use putStringArrayListExtra(), but there shows an error : "The method putStringArrayListExtra(String,ArrayList is undefined for the type bundle." Is there any other method available for passing ArrayList? String test[]=new String[3]; ArrayList al=new ArrayList(); int x,...

Java ArrayList Comparison- TicTacToe

I am trying to make a really simple Tic-Tac-Toe game. I have stored values of "X" and "O" in a 0-8 ArrayList (3x3 square, essentially). I can do the following for each instance of a winning situation: if ((newBoard().get(0)).equals("X") && (newBoard().get(1)).equals("X") && (newBoard().get(2)).equals("X")){ System.out.println("...

OutOfBoundsException for TicTacToe Game; Issue: arrays?

I am the beginnings of writing a tic-tac-toe game. I just ran it and got the following stack trace: Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.rangeCheck(ArrayList.java:571) at java.util.ArrayList.get(ArrayList.java:349) at TicTacToe.isMarked(TicTacToe.java:23) at TicTac...

What will happen to arraylist in this code?

ArrayList userItem = new ArrayList(); userItem.add(item.getUserId()+"|"+item.getEmail()+"|"+item.getImgInstance()); ArrayList userItem = onlineUsers.get(item.getImgInstance()); I want to know what the last line will do to the list will it append the value of onlineUsers.get(item.getImgInstance()) in the previous string or somethign e...

Can I add a group of ArrayList into a single ArrayList?

Can I add a group of ArrayList into a single ArrayList? The ArrayList groups are of different sizes. Then How can I recognize each ArrayList? ...

Fault code: soap:Server Fault string: Server was unable to process request. ---> get out!

Hi, I'm doing web service to import data using the API but I cannot import data because there is an error in soap "Fault code: soap:Server Fault string: Server was unable to process request. ---> get out!" What does it mean? Any help is appreciated. Thanks in advance! :) ...

List versus ArrayList

Ok so I know that Set, List and Map are interfaces but what makes the first line of code any better than the second line? List myArr = new ArrayList(); ArrayList myArr = new ArrayList(); Thanks. ...

Fixing null pointer exceptions in Java (with ArrayList)

Possible Duplicate: Java null pointer exceptions - don't understand why MOVIE.JAVA package javaPractical.week3; import javax.swing.*; public class Movie { // private attributes private String title; private String movieURL; private String year; private String genre; private String actor; // constructor Movie(String t, Stri...