All Questions
1,092
questions
1
vote
2
answers
11k
views
How to add object to JSONArray
I want to add an object to an array. If the data of other_amount is more than zero I want to add one object more. If it's equal to zero, it should add nothing. This is my code:
JSONArray acc_data = ...
1
vote
3
answers
77
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
44
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
4
answers
550
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-...
1
vote
1
answer
5k
views
Need to add multiple items in list - decision table - Drools
I need to create a new multiple instance of objects for the Pojo class in drools decision table. I have implemented using two facts Student fact and subject fact class. I need to fire all the rules in ...
0
votes
1
answer
61
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
votes
2
answers
77
views
Adding Coin Objects to Wallet Objects
I want to create a program where you're able to add and remove coins to a wallet, as well as show the total amount of money in the wallet. All through OOP. I've created a while loop where there are ...
1
vote
2
answers
160
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
109
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 ...
236
votes
7
answers
202k
views
make arrayList.toArray() return more specific types
So, normally ArrayList.toArray() would return a type of Object[]....but supposed it's an
Arraylist of object Custom, how do I make toArray() to return a type of Custom[] rather than Object[]?
-1
votes
1
answer
76
views
How can i make a container of objects and how can i use it in other file
I basicly have an array list in my main class
public static void main(String[] args) {
List escenariosLi = new ArrayList<Escenario>();
String a = "";
escenariosLi.add(0,new ...
1
vote
0
answers
17
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
2
answers
99
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
3
answers
65
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 ...
54
votes
5
answers
56k
views
How to save custom ArrayList on Android screen rotate?
I have an ArrayList with custom objects that I would like to be able to save and restore on a screen rotate.
I know that this can be done with onSaveInstanceState and onRestoreInstanceState if I ...