All Questions
17
questions
-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 ...
-1
votes
1
answer
24
views
I'm doing an assignment for my class where I need to create the functions below for a Path. I'm having trouble on the functions, am I overthinking it?
import java.awt.Point;
import java.util.ArrayList;
import java.util.Scanner;
public class Path
{
ArrayList<Point> pointOne;
ArrayList<Point> pointTwo;
public Path() {
...
1
vote
1
answer
57
views
Creating ArrayList of objects containing ArrayLists as parameters - my code does not seem to create individual ArrayLists?
I am running into problem with a code for a text-based game. My class Locations is meant to load parameters from a "config" text file to create objects.
My current approach is:
I have ...
0
votes
1
answer
500
views
Cannot Find Symbol Error when creating an object
I am creating an ArrayList object that contains a class. However, when I call a method from the WordList() class, it says "error: cannot find symbol obj.numWordsOfLength(2)"
import java.util....
0
votes
1
answer
25
views
I can't seem to figure out how to print the values I've assigned to my objects [duplicate]
This might be an easy answer but I'm new and my professor hasn't been much help, also feel free to correct my terminology. Essentially I have a class "Employee" and I'm trying to add several instances ...
0
votes
2
answers
1k
views
How to fill Object Array and find minimum value for the Object Array
EDIT SOLUTION
Based on forpas code, I move thing around little bit, and now the minimum value displays as expected. Thank you guys for all your help.
public static StudentGrade findMinIndex(...
-1
votes
1
answer
186
views
Can I use public void from a class to make use of it in ArrayList to add age and name?
I'm new to Java and I'm trying to get my head around constructs, classes and objects. I apologise if any of this seems stupid to you.
I have been tasked with creating an ArrayList to hold items of ...
0
votes
3
answers
115
views
Adding an object to an ArrayList that takes another object as a param
Hey everyone I'm trying to brush up on my java knowledge as I have not coded in java in a while. I am working on this store project that has three class. 1.Product 2.InventoryItem & 3.Store
...
0
votes
2
answers
48
views
Java - object reference replaaced in object arraylist before called on
I am having a problem where when I'm debugging my code I notice that my object list array is replacing an object before a new object is added to the list array
Previous Research
I looked researched ...
0
votes
0
answers
12
views
Adding objects in constructor in Java [duplicate]
I'm trying to add every task which has been created in constructor
static private int Id = 0;
private int id = 0;
private Date StartDate;
private Date EndDate;
private static ArrayList<Task> ...
0
votes
1
answer
122
views
Trouble adding object into constructor
For a school project we are supposed to create a simple program that takes some input from the user about Dogs (name, breed, age and weight) and puts them into an ArrayList. Everything seems to be ...
1
vote
1
answer
786
views
Java, making constructor call using list of parameters?
So, I'm reading data from a file and depending on the text read, the program will use a constructor of the class that matches the parameters on the line. So the parameters given by the line of the ...
1
vote
2
answers
223
views
ArrayList<>, adding Objects on creation of another Object
I'm trying to add a series of one Object to another Object in an ArrayList.
In this case, I have "Task", which is a series of Object type "SubTask". Whenever the user presses a specific button, it ...
-1
votes
1
answer
182
views
Android Java constructor creating and holding other type objects and be able to reference that data
So I make class to control many other objects of the same type but when I reference that object to get to a data structure I keep getting null but if I the secondary object is static it works. I'm not ...
12
votes
3
answers
1k
views
type erasure in implementation of ArrayList in Java
I was reading this article on Java Generics and there it is mentioned that the constructor for an ArrayList looks somewhat like this:
class ArrayList<V> {
private V[] backingArray;
public ...