Results 1 to 5 of 5

Thread: Array Problem?

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

    Default Array Problem?

    Hi, I'm not exactly new to java but I do have problems every now and then, anyways I'm having a problem with this code:

    (code is shortened to not include excess code you don't need to know about)

    //code starts here
    public class points
    {
    String[] points;

    public points(Point3f[] pt)
    {
    for (int a = 0; a < getLength(pt); a++) {
    points[a] = pt.toString(); }
    }
    }
    //end of code

    In this part of the code I'm converting Point3f[] into String[] (for java 3d stuff)

    The problem is when this code compile it says:
    'cannot find symbol - method getLength(javax.vecmathPoint3f[])'

    method getLength() is a method from Class Array, pt is an array of point3f objects, I want to get the length of number of points in pt[], how do I rewrite the code to do that? :)

  2. #2
    Lil_Aziz1's Avatar
    Lil_Aziz1 is offline Senior Member
    Join Date
    Dec 2009
    Location
    United States
    Posts
    343
    Rep Power
    11

    Default

    Hey welcome to the forums! Here is how you get the number of elements in an array:

    Java Code:
    for (int a = 0; a < [B]pt.length[/B]; a++) {
         points[a] = pt.toString(); 
    }
    Next time, please put your code in [code] tags like I did above.
    "Experience is what you get when you don't get what you want" (Dan Stanford)
    "Rise and rise again until lambs become lions" (Robin Hood)

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default

    problem is when this code compile it says:
    When posting error messages, please post all of the message, don't edit it.

  4. #4
    m00nchile is offline Senior Member
    Join Date
    Feb 2010
    Location
    Ljubljana, Slovenia
    Posts
    470
    Rep Power
    11

    Default

    If the getLength(Object array) method is in the Array class, then call it as such:
    Java Code:
    Array.getLength(someArray);
    But, since the arrays have a .length field, wouldn't it be easier just to use that? Just like Lil_Aziz1 wrote.
    Ever seen a dog chase its tail? Now that's an infinite loop.

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

Similar Threads

  1. array problem
    By jabo in forum New To Java
    Replies: 2
    Last Post: 03-31-2010, 09:54 AM
  2. Array problem
    By c3jcarmy in forum New To Java
    Replies: 11
    Last Post: 03-11-2010, 02:45 AM
  3. Array problem
    By binarzt in forum New To Java
    Replies: 5
    Last Post: 02-14-2010, 09:01 AM
  4. array problem
    By oceansdepth in forum New To Java
    Replies: 3
    Last Post: 04-05-2008, 02:25 AM
  5. array problem
    By wats in forum New To Java
    Replies: 1
    Last Post: 12-12-2007, 07:08 AM

Posting Permissions

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