Skip to main content

All Questions

0 votes
1 answer
1k views

I want to get my toString method to print all the information of the objects in my array list but I am getting the output with [] brackets [duplicate]

For my code, I have tried using a toString method which I am not sure if is the best way to display information for objects in an array list. I wanted to try a normal method and then just call it but ...
JulianTheProgrammer's user avatar
0 votes
1 answer
123 views

the contents of arraylist are printed using println. I want a similar functionality for my created objects without using toString() function in java

In the image above, the contents of the arraylist is printed using println. I want a similar functionality for my created objects without using toString() function in java please tell me how can i do ...
Rishu Toshniwal's user avatar
0 votes
2 answers
501 views

Printing Objects in an ArrayList

The project requires me to create an ArrayList of objects and then print the complete list. Additionally the maximum amount of characters cannot exceed 280. The objects created are defined in my "...
Stephan Botes's user avatar
1 vote
3 answers
3k views

How can i use a for each loop to print an Arraylist of different objects of different classes

class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); Loan loan = new Loan(); Date date = new Date(); Strings strings = ...
Dedicated User's user avatar
1 vote
2 answers
7k views

How to pass toString from child to parent using super.toString() in Java

Working on a Java project to study Polymorphism. I am trying to learn how to pass a toString() up the line from the bottom child. I have to pass the toString form Hardware.java to Tool.java to ...
Joshua Trimm's user avatar
-7 votes
2 answers
62 views

How do I return/implement the toString for the ArrayList? Also, just want to check that I've correctly created my objects?

import java.util.ArrayList; import java.util.Date; import javafx.scene.shape.Circle; public class List2 { public static void main(String[] args){ Loan newLoan = new Loan(); ...
AVW's user avatar
  • 15
0 votes
2 answers
270 views

How to get one value of an object from only knowing the index ArrayList, Java?

I have created an Arraylist of players for a simple game. I need to display in the console whos turn it is to play. I have a class "Player" where I store name and score. Also a constructor that ...
Je9's user avatar
  • 21
0 votes
1 answer
78 views

Listing Parameters of an Object in an ArrayList

I am trying to create a method to list the elements in an ArrayList, but the method only returns the values of the most recent object: The object: //Constructor for guests at the hotel public Guest (...
FascistHippie's user avatar
0 votes
2 answers
162 views

Need to load objects into an ArrayList read from a text file and output to JTextField?

I'm working on a project and I am suppose to read in the data from a text file called "stars.txt", create objects for all the sales reps in the file, load the objects onto an ArrayList and display ...
faultline's user avatar
1 vote
3 answers
120 views

How do I return an ArrayList<String> from ArrayList<ArrayList<String>>.get()

I have an ArrayList like : ArrayList<ArrayList<String>> test for(int i = 0; i < test.size(); i++) { ArrayList temp = test.get(i); } It turns out now, that I cannot do Arrays....
gran_profaci's user avatar
  • 8,339
0 votes
4 answers
302 views

Constructing objects while adding to ArrayList

public class ComputerKit { private ArrayList <ComputerPart> parts = new ArrayList(); //constructor public ComputerKit(ComputerPart ... cp){ for(int x=0;x<cp.length;x++){ parts.add(...
user2134108's user avatar
0 votes
2 answers
368 views

Able to print only some objects in ArrayList by overwriting toString()

I have some problems of printing out the object after overwriting toString(). Without overwriting toString(), I can print out the object references without any error. However when I try to overwrite ...
yong's user avatar
  • 3
0 votes
5 answers
2k views

Java ArrayList Help!

I am working on learning java a little, and i found this question in a java text book on Google books, I have been working on it for a while, and for some reason these seems like it should be simple. ...
Madison's user avatar
  • 71