Skip to main content

All Questions

Tagged with
0 votes
0 answers
26 views

Accessing methods of methods of interfaces directly created in Arraylist

I have created an ArrayList named Accounts and then directly created a object in it using add method. Is there a way in which I can access the methods of the object? public class Main { static ...
user avatar
0 votes
3 answers
129 views

Object Arraylist fails to store objects [duplicate]

I am new to Java and I am trying to create a library program containing two separate class files. One file contains the Book class while the other contains the Library class. Book class: public class ...
yungstirjoey666's user avatar
0 votes
1 answer
1k views

Method Calls from Child Class objects in arraylist of parent class Java

So I have a parent class with a series of child classes for some objects I need to use in a program. class parentClass{ } class childClass1 extends parentClass { } class childclass2 extends ...
Conor McV.'s user avatar
0 votes
3 answers
74 views

Create a method for inputting objects in an ArrayList

I have a task to create a method which holds the same variables as the already created constructor for my objects whicj i have added 3 of them to the ArrayList. When the method is called in the main ...
Blagovest Stoyanov's user avatar
0 votes
0 answers
33 views

Why is this toArray() method not working? [duplicate]

I am making a simple blackjack program in java, in which there is a Dealer class that extends the Player class. The problem in the code below is that when calling the Player.hit() method is called, I ...
Meta Programming's user avatar
0 votes
5 answers
68 views

Accessing attributes, methods of different class objects stored inside an object type Arraylist

I have different weapon classes with various attributes and functions (some of which are similar). I am trying to iterate through objects of classes and trying to access those attributes based on ...
Nirmalya Basu's user avatar
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 ...
2004DodgeNeon's user avatar
3 votes
4 answers
11k views

Java - How to find students with their highest marks writing a method in a Student class?

I'm a beginner in java and got stuck in one task. I will be very thankful if anyone could help me. I have a class Student with these attributes - name, chemistry mark, mathematics mark and physics ...
stavla's user avatar
  • 31
-1 votes
1 answer
5k views

CodeHS Billboard Class AP CS A

I am struggling with the CodeHS Java problem Billboard Top 10. I am trying to reference a Musician object within the top10 ArrayList, but I keep getting the error: non-static variable top10 cannot ...
gk67's user avatar
  • 1
-1 votes
1 answer
340 views

How do I create a Dynamic Object with a ArrayList, which can use Methods?

I got a Task for my education, and I need to program a delivery site. I have classes called "Pizza", PizzaReader2 (because 1 was just a test) and the main class PizzaApplication. So the PizzaReader ...
BlitzDodo's user avatar
0 votes
1 answer
42 views

Transferring one object's ArrayList's contents to another [duplicate]

I'm trying to transfer the contents of an ArrayList from one Book object to the other Book object. The method would be called as bookA.transfer(bookB); However, with the code below, I get an error ...
John Kerry's user avatar
0 votes
1 answer
38 views

Sorting an ArrayList object populated with custom objects with two data fields each

stuck on a problem with sorting ArrayLists. I'm sure the answer is really easy and something I just keep overlooking, but I've been working on this for the past many hours straight and just need ...
Cheyko's user avatar
  • 41
1 vote
3 answers
154 views

String from object does not equal string from the same object in an ArrayList

I'm building a catalogue using an ArrayList to hold an object called boot. I haverun into a problem with one of the methods in my catalogue class. The method is supposed to run through the catalogue ...
Bryan Guzman's user avatar
0 votes
1 answer
72 views

Sorting an ArrayList as objects are being put into them

Im currently working on a class that includes a method "add" that adds my specific object to my ArrayList which is a field instantiated in my constructor. The purpose is to obviously add the object to ...
Cody S.'s user avatar
0 votes
1 answer
90 views

Pass a created object from one class to another and add to ArrayList?

I´ve created a function where you add a result for a participant in a event. Now I want to pass the created object to an addResult-method in my participant class and thereafter add it to an ArrayList ...
Andpej's user avatar
  • 99

15 30 50 per page