Skip to main content

All Questions

0 votes
1 answer
185 views

How to stop the modification of an object in one ArrayList from also modifying the same object in another ArrayList [duplicate]

I have the following code which is designed to find an object from one arraylist by comparing to a string, then add the object to another arraylist, then modify a parameter of the object in the second ...
LordGibbous's user avatar
0 votes
1 answer
1k views

Adding new objects to an ArrayList using a constructor

I have to make a small app as an class exercise which simulates an mobile phone which is able to add and list contacts. In the main I have to create a new mobile phone by its brand and to add new ...
O. Bogdan's user avatar
0 votes
2 answers
2k views

Adding objects from one class to an ArrayList in another class

I'm new to java and I'm trying to write my first "bigger" program, with several classes. I have created an ArrayList in the class "CompetitionProgram" and it's declared as private. public class ...
Vicky123's user avatar
1 vote
1 answer
1k views

How to do an add method for objects in an ArrayList

So for an assignment in my programming class, we are supposed to make an ArrayList to store objects of a class created in a previous assignment. My only problem is that i'm not exactly sure how to ...
Abbey S's user avatar
  • 111
-1 votes
1 answer
2k views

C# using ArrayList from another class

I have one class Racun.cs public class Racun { private string _nazivKupca; public string NazivKupca { get { return _nazivKupca; } set { ...
Goran's user avatar
  • 1,239
0 votes
1 answer
35 views

adding in a ArrayList by casting an Object, from table of Objects, into double

Why the cast (double) doesn't work ? I nead to add doubles to my ArrayList. import java.util.ArrayList; import java.util.ListIterator; public class Vecteur extends ArrayList implements Cloneable{ ...
Simo's user avatar
  • 161
-1 votes
1 answer
59 views

Overwriting in add object to arraylist

this thing right here is giving me some headache for a while, I'm trying to find the problem and can't find an answer. Basically, it's overwriting every single previous object in the list. public ...
Sam's user avatar
  • 1
0 votes
2 answers
2k views

Adding and setting new object in ArrayList at specific index (JAVA)

I made some projects with ArrayList. They have same problem with adding new object. My goal is to add new Object at specific location. For instance, each index hold four strings. index 0: New York ...
Jeffrey Zong's user avatar
2 votes
6 answers
14k views

Java Add Object to ArrayList error

I'm new to coding java and would love some help. I'm trying to add an object of the class Fish to an arraylist call fishList in my main I have for example public static void main(String[] args) {...
Ser Davos's user avatar
0 votes
3 answers
7k views

Adding objects to an arraylist in java

I am trying to write a solitiare game on java. I'm trying to add the card objects to my arraylist but the MakeDeck function is not working properly. public class PileOfCards { public ArrayList<...
kndmrl's user avatar
  • 3
1 vote
1 answer
28k views

How do I add a new Object to an ArrayList?

I’m trying to add a new object to an ArrayList. Each Item object will have 3 attributes: itemNum info cost I also have 3 classes: Item class defines the single items stored in the catalog. ...
Dan S.'s user avatar
  • 87
0 votes
2 answers
5k views

How to write and retrieve objects arraylist to file?

I have an object arraylist, can someone please help me by telling me the most efficient way to write AND retrieve an object from file? Thanks. My attempt public static void LOLadd(String ab, ...
user1799252's user avatar
1 vote
5 answers
6k views

While and for loops for adding to two dimensional array

I have an arrayList which contains Objects. Each object contains a number of strings. I am trying to take these strings and add them to a two dimensional array. public void iterateRow(Row row) { ...
Hoggie1790's user avatar
0 votes
4 answers
2k views

Java: Can't add an int to an arraylist

I've created an empty arraylist here: private ArrayList<OrderItem> conveyorBelt = new ArrayList<OrderItem>(10); And in the same class, I've created a method where I add item into the ...
hteeT's user avatar
  • 3