ive created an array list but every time i try and print the conents, instead of giving me a list it gives me the class name followed by @e41bc3 random numbers and letter.
any ideas on how to print the contents?
cheers
DGXI
0
Newbie Poster
Recommended Answers
Jump to PostDo it with and without toString() method
import java.util.ArrayList; import java.util.List; public class Main { public static void main(String[] args) { List<Any> list = new ArrayList<Any>(); list.add(new Any(1)); list.add(new Any(2)); System.out.println(list); } } class Any { private final int i; public Any(int i) { this.i = i; …
All 2 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.