Results 1 to 3 of 3

Thread: array.width?

  1. #1
    noobgrammer is offline Member
    Join Date
    Jun 2010
    Posts
    9
    Rep Power
    0

    Red face array.width?

    Hey, so I have a array list of floats which I believe you call it:
    Java Code:
    float[][] tre;
    Anyways I want to know how long the 2nd box is, or the list part if you know what I mean.

    tre.length gives me the length of the 1st box, what do I do to find out the 2nd box?

    tre.width doesn't work

    thanks

  2. #2
    mangstadt is offline Member
    Join Date
    Jul 2010
    Location
    USA
    Posts
    19
    Rep Power
    0

    Default

    When you declare a multidimensional array, you're declaring an array that holds arrays. So to get the length of each array within the array, you do this:

    Java Code:
    tre[0].length
    tre[1].length
    //etc

    The sub arrays can actually vary in length, but you'd never want to do that in practice I don't think. :) So this is actually legal:

    Java Code:
    float[][] tre = new float[3][];
    tre[0] = new float[2];
    tre[1] = new float[7];
    tre[2] = new float[10];

  3. #3
    noobgrammer is offline Member
    Join Date
    Jun 2010
    Posts
    9
    Rep Power
    0

Similar Threads

  1. Width (-1) and height (-1) cannot be <= 0
    By LovJava in forum AWT / Swing
    Replies: 5
    Last Post: 04-24-2010, 01:16 AM
  2. How get width of string?
    By artemff in forum CLDC and MIDP
    Replies: 1
    Last Post: 12-13-2009, 03:52 PM
  3. Get Image Height and Width
    By neeraj.singh in forum AWT / Swing
    Replies: 10
    Last Post: 02-18-2009, 02:09 PM
  4. ComboBox Fix Width
    By Azndaddy in forum New To Java
    Replies: 2
    Last Post: 05-29-2008, 05:23 AM
  5. how to retrieve the width of the column
    By katie in forum New To Java
    Replies: 1
    Last Post: 08-06-2007, 11:56 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
  •