Skip to main content

All Questions

Tagged with
1 vote
3 answers
101 views

Can an object belong to both an array and arraylist simultaneously in Java?

I am struggling to write a code sample where an object can belong to an array and arraylist simultaneously and where modifying in arraylist or the array changes the object? See example where I was ...
JSNoob's user avatar
  • 13
-1 votes
1 answer
56 views

Why is the second instantiation of the Player object rewriting the first in this Java program?

I am attempting to write a program that will allow a user to input four characteristics of a "Player" object and add that object to an array list of other Player objects. However, it seems ...
LibreEstVitae's user avatar
0 votes
1 answer
395 views

Mooc.fi Java 1 -Part07_07 Recipes

(Apologies for the formatting this is my first post) I am looking at teaching myself Java through mooc.fi Java from the university of Helsinki, I have been attempting this problem for 4 days straight ...
Ashton Seloka's user avatar
0 votes
4 answers
203 views

Do I need unique names for all my objects in a list?

I am a first year Comp Sci student. For part of an assignmentI have for my Java class. I need to create a deck class that is an ArrayList containing Card objects. Here is an example of a card object I ...
CynicalBlitz's user avatar
2 votes
3 answers
74 views

Split an List of objects based caseNumber into a new List of objects

I have an List of Messages objects. My message object consist of sender and CaseNumber. A SQL query is pulls all the messages into a list. In this list I have multiple of the same CaseNumber. What ...
user22553624's user avatar
-1 votes
1 answer
72 views

How to add objects to list without having array brackets

I have a for loop in which I add some attributes to the object and at the end I need to have a string (to pass it as a query parameter) I need {"items":[{"itemsCode":"item1&...
jacob1989's user avatar
0 votes
4 answers
891 views

Difference between Array and ArrayList<> in Java in terms of memory allocation?

I came accross an article which had a question- Contiguous memory locations are usually used for storing actual values in an array but not in ArrayList. Explain. https://www.geeksforgeeks.org/java-...
ayush's user avatar
  • 686
0 votes
1 answer
19 views

Trying to Compute the differences in two different ArrayLists of Objects with Instance Fields of Type Integer[JAVA]

package pckg; import java.util.ArrayList; import java.util.HashMap; public class Tester { public static void main(String[] args) { ArrayList<TesterObj> my_first_objects = new ...
Dean Loyals's user avatar
-2 votes
1 answer
3k views

How to display a list of objects as a JList in java swing?

We are asked to build a system in Java Swing no drag and drop and I cannot understand how to display a list of objects in a JList. I have a GUI class that creates a JFrame, JPanel, and an empty JList ...
rainbow's user avatar
0 votes
3 answers
1k views

How to get data from List<Object[]> using java 8

Trying to get a data from DB using JPA. My Data format was like [[John,Wick,New York],[Walter,White,New Mexico]] And am using below code the get the data from List<Object[]> and with iteration ...
tisispa1's user avatar
  • 233
0 votes
1 answer
79 views

Referencing an interface from ArrayList

I am having trouble understanding ((Edible)objects[i]).howToEat() at line 7 in the java code example given below. Edible is an interface which contains abstract method howToEat() and I understand that ...
ProgrammingStudent's user avatar
-1 votes
2 answers
79 views

Java - from Array to linked ArrayList why it doesn't affect all int values?

I am studing Java, i have simple Array linked to ArrayList, it is fixed size i can change values inside array or list without change length. So i tried to change all elements of the Array to see ...
Lukas's user avatar
  • 25
0 votes
1 answer
40 views

how to return numbers by column from objects that have array list attribute

I have a class where I am creating different "Processes", an attribute of this class is an linked list of Integers. I have created different class objects and to make it easy to loop through ...
javaloaf's user avatar
0 votes
2 answers
382 views

Java.lang.NumberFormatException when trying to read in a file, so I can use the data with my objects

I keep getting this error when I'm trying to read in a file and add the data to my objects. Can someone please help me? Here is the error: Exception in thread "main" java.lang....
Ish Higareda's user avatar
0 votes
1 answer
64 views

JAVA Attribute of ArrayList<Object> not returning values

Class Hospital package app; import java.util.ArrayList; import app.Department; public class Hospital { String hospitalId; String hospitalName; int departmentCount; ArrayList<...
Joe's user avatar
  • 83

15 30 50 per page
1
2 3 4 5
62