Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: 3d list array

  1. #1
    Junior Member spoX's Avatar
    Join Date
    May 2012
    My Mood
    Thanked 0 Times in 0 Posts

    Default 3d list array


    I have some problem in understanding how to use a 3 dimensional ArrayList.

    Heres hows it looks so far.

    I dont understand how to retrive values from the list.
    Tried all sorts of code like get_material to retrive string value.
    But maybe I got it wrong in the initialising?

    gui class....
    		ArrayList<material> material_List = new ArrayList<material>();
    		material_List.add(new material(0, "Silver", 427));
    		material_List.add(new material(1, "Copper", 398));
    		material_List.add(new material(2, "Gold", 315));
    public class material {
    	private static String material;
    	public material(int id, String material, double materialValue){
    	public static material create(int Id, String material, double materialValue){
    		return new material(Id, material, materialValue);
    	public String get_material(){
    		return material;

    If u can help, thanks.
    -sorry for my bad spelling English.

  2. #2
    Super Moderator
    Join Date
    Jun 2013
    So. Maryland, USA
    My Mood
    Thanked 697 Times in 679 Posts

    Default Re: 3d list array

    The class 'material' should begin with a capital letter, as in Material.

    The ArrayList you've built is 1-dimensional rather than 3, and the single dimension is filled with Material objects.

    Since each element in the arraylist is a Material object, Material methods could be used to obtain details about those objects/elements. For example, from the code you posted above, to get the metal from the first element, the code would look something like:

    material_List.get( 0 ).getMetal();

    Assuming there was a method Material.getMetal() that returns the metal type of the object.

Similar Threads

    By stresstedout in forum What's Wrong With My Code?
    Replies: 4
    Last Post: April 9th, 2014, 01:56 PM
  2. Array List help
    By popnfresh in forum What's Wrong With My Code?
    Replies: 3
    Last Post: March 6th, 2013, 07:41 PM
  3. Converting Two dimensional array into an Array list
    By NewbieJavaProgrammer in forum Object Oriented Programming
    Replies: 11
    Last Post: September 29th, 2012, 04:23 PM
  4. Array List of Array Lists working for first item but not for second.
    By javapenguin in forum Collections and Generics
    Replies: 6
    Last Post: February 15th, 2012, 05:12 PM
  5. Array List
    By nadirkhan in forum Collections and Generics
    Replies: 6
    Last Post: September 9th, 2011, 09:39 AM