Results 1 to 7 of 7
  1. #1
    rblmvs is offline Member
    Join Date
    Apr 2011
    Posts
    3
    Rep Power
    0

    Default java 2 dimensional no size list

    Hi,
    i want to 2 dimensional no size list, like matrix. But i dont find. Please help me.

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Look up lists and how to use them.

  3. #3
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,305
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by rblmvs View Post
    Hi,
    i want to 2 dimensional no size list, like matrix. But i dont find. Please help me.
    Do you want this?

    Java Code:
    List<List<Double>> matrix= new ArrayList<List<Double>>();
    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    rblmvs is offline Member
    Join Date
    Apr 2011
    Posts
    3
    Rep Power
    0

    Default

    Quote Originally Posted by sunde887 View Post
    Look up lists and how to use them.
    thanks for your help !

  5. #5
    rblmvs is offline Member
    Join Date
    Apr 2011
    Posts
    3
    Rep Power
    0

    Default

    Quote Originally Posted by JosAH View Post
    Do you want this?

    Java Code:
    List<List<Double>> matrix= new ArrayList<List<Double>>();
    kind regards,

    Jos
    yes i tried this but i thought if i want to 4 dimensional list List<List<List<List<Double>>>> ?

    Double[][] matrix = new Double[][](); Like this ?

  6. #6
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    No, in a list you specify what it's a list of with generics.

    So the list jos showed you was a list where each item is a list of double.

    A three d list would be a list where each item is a 2d list.

    A four d list would be a list where each item is a 3d list

    Java Code:
    List<List<List<List<Double>>>> fourD = new Arraylist<List<List<List<Double>>>();
    Is what it should loop like, you can test it by adding some items to it and print them.

  7. #7
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,305
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by rblmvs View Post
    yes i tried this but i thought if i want to 4 dimensional list List<List<List<List<Double>>>> ?

    Double[][] matrix = new Double[][](); Like this ?
    Yep that'd model a four dimensional List of Doubles, but what is that two dimensional array doing there?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Help with java sorting two dimensional array
    By Joycey in forum New To Java
    Replies: 2
    Last Post: 03-27-2010, 02:36 AM
  2. how to create list of list in java ???
    By ilayaraja in forum Advanced Java
    Replies: 1
    Last Post: 10-26-2009, 04:30 PM
  3. Setting frame size to the size of an image
    By Yoruichi in forum AWT / Swing
    Replies: 5
    Last Post: 04-22-2009, 04:37 PM
  4. Java heap size
    By jmdrocks in forum Eclipse
    Replies: 2
    Last Post: 12-12-2008, 06:10 AM
  5. How to get Image size in Java
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 06-23-2008, 11:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •