I have some data stored as ArrayList. And when I want to backup this data,java bounds two objects forever. Which means when I change values in data ArrayList this changes come ... |
I was looking through the Java documentation, and I came across the clear() method of ArrayLists.
What's the use of this, as opposed to simply reassigning a new ArrayList object to ... |
I am willing to create a list of options to test something.
I was doing:
ArrayList<String> places = new ArrayList<String>();
places.add("Buenos Aires");
places.add("Córdoba");
places.add("La Plata");
I refactor the code doing:
ArrayList<String> places = new ArrayList<String>(
...
|
I am asking for help on self-help, which is kind of an oxymoron. How do I bug you nice folks less by solving more of my own problems?
I am in ... |
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 need little help on a homework assignment. I have to create a 10 by 10 ArrayList, not an array that would make too much sense. This is what I have ... |
i'm trying to get my program to compile but its giving me 5 errors
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;
import java.lang.*;
import java.text.*;
import java.net.*;
import java.util.Scanner;
public class AddressBook extends JFrame implements ActionListener
{
FlowLayout leftLayout;
...
|
|
I know that I am missing something simple here. I have got this homework all done except for moving through my ArrayList. This is a undo feature of a calculator ... |
Ok, so I'm tyring to iterate through an ArrayList and remove a specefic element. However, I am having some trouble using the For-Each like structure. When I run the following code:
ArrayList<String> ...
|
I'm a bit new to java, so please bear with me.
I have a class that contains 2 arraylists which i'm trying to store objects into, one for each object type. ... |
I was wondering if anyone knows the growth policy of ArrayList in Java 1.6? The java doc says
The details of the growth policy are not specified beyond the ... |
We're getting this error
java.lang.NullPointerException
at java.util.ArrayList.<init>(Unknown Source)
at de.mystuff.ExtendedArrayList.<init>(ExtendedArrayList.java:38)
where ExtendedArrayList:38 is
new ArrayList(new ArrayCollection<E>(data));
In short: the ArrayList constructor sometimes seems to choke on our home grown ... |
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 ... |
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)?
|
public class Maze
{
public static final int ACTIVE = 0;
public static final int EXPLORER_WIN = 1;
public static final int MONSTER_WIN ...
|
I have written this code to join ArrayList elements:
Can it be optimized more? Or is there a better different way doing this?
public static String join(ArrayList list, char delim) {
...
|
I have the following fucntion.
func(ArrayList `<String>`[] name) { ........ }
The function fills the ArrayList[]. (I don't want to return the ArrayList[])
However, in the caller function the ... |
while profiling a java application that calculates hierarchical clustering of thousands of elements I realized that ArrayList.get occupies like half of the CPU needed in the clusterization part of the execution.
The ... |
I have a function that shrinks the size of a "Food bank" (represented by a rectangle in my GUI) once some of the food has been taken. I have ... |
I trying to find whether the elements of 2 arrayLists are match or not.
But this code give me error Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException since some of the elements are null. ... |
Primitive types are not allowed in ArrayList, source. Partial solution: you can wrap prim.types such as int to Integer to form an extra class but a side effect. I ... |
I have 10 instances of the class movie which I wish to add to an Arraylist named Catalogue1
in a class containing a main method I write the following
ArrayList catalogue1= ...
|
I am looking for a pre-built Java data structure with the following characteristics:
- It should look something like an ArrayList but should allow indexing via double-precision rather than integers. Note that ...
|
I need to know if i store my data in an ArrayList and I need to get the value that I've stored in it
For example : if I have an ... |
I mostly write in C but am using Java for this project. I want to know what Java is doing here under the hood.
ArrayList<Integer> prevRow, currRow;
currRow = new ArrayList<Integer>();
for(i =0; ...
|
I have been staring at this code all day now, but just can't get it right.
ATM I am just pushing codeblocks around without being able to concentrate anymore, with the ... |
here is the whole program:
public class ListMerge
{
public static void main( String[] args)
{
Scanner input = new Scanner(System.in);
...
|
I am having one problem in java arraylist. I am good in databases :) We normally use
"group by" to group rows. I want the same thing but in java for one ... |
Is an empty Arraylist (with nulls as its items) be considered as null? So, essentially would the below statement be true:
if (arrayList != null)
thanks
|
I have gotten a float array stuck inside of a ArrayList. the arraylist contains a Boolean and the afore mentioned float array. my courrent code to get it out (which doesn't ... |
I really do not know if the title is appropriate or not.
I have 2 options:
OPTION 1:
Class A {
ArrayList<B> BList = new ArrayList<B>();
public B[] getBList() {
...
|
package Algorithms;
import cs1.Keyboard;
import java.util.*;
public class SieveofEratosthenes2 {
public static void main (String[] args){
//input number and create an array with the ...
|
Have coded in many languages before but new to Java.
I want to create an array whose members are of type
public class data
{
...
|
I have an arraylist of database records. I want to put it in my J2ME List. But there is no split or arraylist in J2ME. How can I do it? A ... |
What data structure does an ArrayList use internally?
|
I have an ArrayList which stores 52 card objects like so:
public class Pack
{
private ArrayList<Card> cards;
private Card RandomCard;
public static void main(String[] args) ...
|
I have a hashMap. Each "Value"is going to be a a list which will be mapped later on with my "Key"s. List is desired to look like this:
[length,time][length,time][length,time]
For example:
Key{srcAddr=x, dstAddr=y, srcPort=12345, ... |
I wish to
- Avoid duplicated item being inserted.
- When I iterate through the collection class, the returned item is same as insertion order.
May I know, what thing I should consider, to choose either ... |
What is the best practice to initialize an ArrayList in Java?
If I initialize a ArrayList using new operator then, the ArrayList will by default have memory allocated for the 10 buckets ... |
I'm trying to create 5 ArrayLists of various size, fill them with random numbers between 0 and 1, and then time (and print) how long it takes to iterate through each.
I ... |
Currently the code below will give me a line by line listing of the values, if i wanted to sum the values for one total, can someone give me an example ... |
I need help. For this specific method. I am trying to get it to return an arraylist that I tokenized.
public ArrayList read (){
BufferedReader inputStream = null;
try {
...
|
I am having difficulties with a program that I have been working on all day. I am trying to read a text file and read each line one at a ... |
I'm having issues formatting an input String into an ArrayList. I commented out some of the things I've tried. Initially I tried to put the input into a string ... |
Alright so I'm trying to get this class work:
public boolean hasPoint(Point p){
for (int i=0; i<this.points.size(); i++){
// Right here
...
|
ArrayList queryParms = new ArrayList();
StringBuffer sql = new StringBuffer();
sql.append(
"SELECT A.FLDREC_NUM, " +
"@CHARDATE(A.FLDDATE), " +
"T.FLDDESCR, @DEC(A.FLDLEVEL,3) " +
" FROM @SCHEMAALCOHOL A LEFT OUTER JOIN @SCHEMADRUGCAUS T " +
" ON A.FLDREASON = T.FLDCODE ...
|
public boolean addPoint(Point p){
points.add(p);
return points.add(p);
extremes();
}
Alright so when I run this code the main class calls addPoint and ... |
I have a homework assignemnt that I have been working with for the past few days and I just keep on going circles and circles thinking that I got the codes ... |
I have a homework assignemnt that I have been working with for the past few days and I just keep on going circles and circles thinking that I got the codes ... |
Just getting back into using C++ and trying to convert a simple Java program I wrote recently.
What's the preferred equivalent to the Java ArrayList in C++?
|
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 ... |
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 ... |
I have issues getting my ArrayList to add properly. When I print the ArrayList after the for loop has finished, the ArrayList is the correct length, but every element is the ... |
I have an ArrayList of Strings in my java bean. I want to be able to add/remove from this list at design time in the property editor. How do ... |
I have two arraylist filelist and imgList which related to each other, e.g. "H1.txt" related to "e1.jpg". How to automatically randomized the list of imgList according to the randomization of fileList? ... |
I've tried comparing this to examples and I just can't seem to find out why this will not compile so I was hoping for some insight.
ArrayList<Integer> listOfPrimeNumbers(initialCapacity) = new ArrayList<Integer>( );
is ... |
hi I have a parent class that is Abstract Employee and I have childrens Secretary, Engineer, Technician If i have ArrayList<Employee> employees; and in a for loop I have randomly made ... |
list all modules in the ArraryList? -
I thought it'd be something like below but this won't compile (error - cannot find symbol - method list).
/**
* This method lists all ...
|
I have xml document that contains an array/list of complex elements. I would like to generate a PDF file such that each complex element is displayed on a new page. I ... |
I have recently found what appears to me to be a new syntax for statically initializing an ArrayList:
new ArrayList() {{
add("first");
add("second");
}};
My question is, what is really ... |
I'm fairly new to ArrayLists anyway but I need them for this project I'm doing so if you guys could help me I would be more than grateful!
Basically, I need to ... |
I am having problems while listing an ArrayList. My code:
Iterator<String> iterator = (Iterator<String>) myList.iterator();
while (iterator.hasNext()) {//List tagListAux
System.out.println("Test -> "+iterator.next());
...
|
My question is regarding declaring an arraylist as final. I know that once I write final ArrayList list = new ArrayList(); I can add, delete objects from this list, but I ... |
So I have this function, combinations, which adds to an arraylist all permutations of a string.
public static void combinations(String prefix, String s, ArrayList PermAttr) {
...
|
I am using an if statement as shown below,
if(sign.size()==0)
Here sign is of the type ArrayList<Character>
I am trying to add a char to the ArrayList
But its not working. Is there ... |
I have a 2D arraylist containing 4 cols. I want to add a 5 th column to this arraylist.
the fourth col is a set of values based on which the result ... |
I am trying to write a getter for an ArrayList in Java such that the list returned cannot be modified (ideally at compile time). I know there must be some simple ... |
public class ButtonPanel extends JPanel
{
private JButton[] buttons;
private ArrayList<Character> playerSequence;
private static final Character firstChar = 'A';
...
|
Just a very small question... I seem to run into too much complexity here: I have to realize an index-structure like {42, someString}. I tried:
Object entry[][] = new Object[1][1];
ArrayList<Object> my_list = ...
|
Please help me explaning this. I can't seem to figure out why this produce a null pointer exception
/* Try to find customer in customer list, if not in list add to ...
|
I've got an ArrayList called conveyorBelt, which stores orders that have been picked and placed on the conveyor belt. I've got another ArrayList called readyCollected which contains a list of orders ... |
I've been asked to create a method that returns all of the factors as an array list. Any help would be appreciated as I've been stuck for some while now.
/**
* ...
|
I am adding parsed value in an ArrayList. I am getting lot of parsed value in webservice. So I am getting out of memory error how to avoid that ?
... |
I am having trouble starting out this program. I am supposed to write a program that will populate an ArrayList by asking the user for 10 numbers.
After the list is made ... |
import java.util.ArrayList;
public class WTFAMIDOINGWRONG
{
public static void main(String[] args)
{
ArrayList<Integer> intsAR = new ArrayList<Integer>(5);
...
|
Why am I getting these 4 warnings from -Xlint and what should I do about them? I'm just starting in Java, so am likely missing something obvious.
import java.util.*;
class CompareGerbils implements Comparator ...
|
I am currently working on a lab and would like to know how to handle the following problem which I have spent at least two hours on:
I am asked to create ... |
I am new to Java, please help me.
My program is
import java.util.*;
import java.lang.*;
class Test
{
public static void main(String[] args)
{
...
|
I'm trying to add Cards to ArrayList deck, but it doesn't seem to work(most of the code is an example on oracle.com ). I'm probably doing something really stupid, but I ... |
What changes to be done in ArrayList to make it behave like a Set (means it should not accept any duplicate values).
|
Possible Duplicate:
Storing primitive values in a Java collection?
ArrayList accepts only reference types as its element, not primitive datatypes.
When trying to do so it produces ... |
I have made an ArrayList of type CartItem, basically it stores all the CartItems in one list.
Now once a CartItem has already been added, instead of adding the same CartItem again, ... |
I'm trying to add an object to an array list but having a bit of difficulty. I know my problem, but not how to fix it. Basically, the problem is that ... |
I have a Register class contains 8 sets& gets methods
using:
public class Register {
public Register(String Username) {
JFrame myFrame = new JFrame();
}
public ...
|
How would you extract the data as follows:
I want to extract from this arraylist:
[{itemname=Original, number=12}, {itemname=BBQ, number=23}, {itemname=CatchUp, number=23}]
This array:
{"Original":12,"BBQ":23,"CatchUp":23}
Thanks in advance! Here's the code used to generate the hashmap:
ArrayList<HashMap<String,String>> list ...
|
I am making a program that makes use of two Array Lists. I've researched how to write the objects to binary and I've tried implementing it but it never works correctly. ... |
Occasionally I see somebody create an arraylist like this, why?
List numbers = new ArrayList( );
Instead of:
ArrayList<something> numbers = new ArrayList<something>();
|
public void critReactRoomStateChange(String command, PC pc, String name) {
Creature temp = null;
for (int i = 0; i < getCount(); i++) {
...
|
I want to add both String and integer type of value in arraylist.
For example i have array list in which i want to add name of the persons and ... |
public ArrayList<Person> people;
Is this how you would instantiate the people variable as a new empty ArrayList of Person objects?
ArrayList<Person> people = new ArrayList<Person>();
And is this how you would add newMember to ... |
Whenever I run this method the print goes perfectly fine so the argument is passed and not null. Still it gives a NullPointerException when the argument is added to the children ... |
I m having a 2d arraylist and inside a loop i want to parse every 1d list of the 2d list to a temporary list. Also I want at the end ... |
Assuming that I have a class named Class,
And I would like to make a new ArrayList that it's values will be of type Class.
My question is that: How do I do ... |
I'm trying to write a simple program in Java in educational purposes.
Basicly you can add students and those grades and after all collect some statistics like average students grade or filtering ... |
i know how to add many things into arraylist at once, like:
String [] things = {"eggs ", "pie ", "lasers ", "hat "};
List list1 = new ArrayList();
for (String s: things)
...
|
In java I have an arraylist that holds the following
List<IMyInterface>
I am returning it in a function
List<? extends IMyInterface> getList()
Now I wanna do the following ... |
I have a bean class ReportVO which has fname,lname and an ArrayList of SubReportVO bean.
I want to use the member variables of SubReportVO bean from that arraylist to fill the report ... |
I have an arrayList called A, say, which is non-empty.
I create another arrayList, B, and put in some elements of A.
for(someobject obj : A){
...
|
I have an application that bounces Shapes around inside a JPanel. Whenever shapes hit a side they will bounce off in the other direction. I am trying to add a new ... |
This Program WAS homework. We have already finished it and are good to go. I was wondering if there is a more streamlined way of writing this program? The program is ... |