All Questions
1,086 questions
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 ...
-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 ...
0
votes
1
answer
394
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 ...
1
vote
2
answers
380
views
C# Add List class to new List class without looping
I have a list of users returned in a class
My Class: List
public class EmployeeList
{
public int Emp_No { get; set; }
public string Sys_Prefix { get; set; }
public short Company_No { get; ...
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 ...
1
vote
0
answers
19
views
Can't add elements of another class (same package, public) to Array list. I was doing it before(im sure about it, can send code) but now i cant
I can create new Task object, ArrayList of the Task, but when I'm trying to add (early created or to create it when adding) Task object to List, it says that "Cannot access todo.Task."
I was ...
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 ...
-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&...
0
votes
0
answers
25
views
Serialization and deserialization a list
I'm trying to write ArrayList to a file, and then read a random string from the ArrayList.
In the code, I'm trying to output at least the entire ArrayList from the file (in order to select a random ...
0
votes
4
answers
143
views
How to print a name by a given ID
var people = [
{name: 'John', id: [34, 44, 77]},
{name: 'Jose', id: [43, 54, 65]},
{name: 'Hanna', id: [56, 34, 98]}
];
var peopleFinder = people.filter(function(b){
return b.id === ...
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-...
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 ...
1
vote
1
answer
71
views
Flutter: How do I iterate a nullable table and add each row object to my object list
Problem: The method 'query' can't be unconditionally invoked because the receiver can be 'null'.
1 - I already checked that the _database is not null. How do I get around this?
2 - I'm not sure how to ...
-2
votes
2
answers
101
views
How to parse an objects with array index to object array with key value pairs
Convert this object Students object to one Students array
{"SubmitBy":"SK", "Students[0].name":"Jhon", "Students[0].age":"15", "...
-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 ...