Results 1 to 8 of 8
  1. #1
    bert682 is offline Member
    Join Date
    Oct 2009
    Posts
    6
    Rep Power
    0

    Default Get int from Array

    Hey guys,
    Have a small problem in extracting an int value from an array. Im modifying code for a class exercise so im not 100% sure of all the code. Anyway, here is what I have extracted as the code relating to the array.

    Java Code:
    private static final int BallArraySize = 10;
    private Ball [] ballArray = new Ball [BallArraySize];
    I thought that the following would work, it is within a for loop;
    Java Code:
    int current = Array.getInt(ballArray,i);
    but it doesn't.

    Any ideas?

    Thanks

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    11

    Default

    Java Code:
    int current = ballArray[i];
    P.S Better read the array tutorial.

  3. #3
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    11

    Default

    Java Code:
    int current = ballArray[i];
    returns a Ball, not an int. Did I miss anything?
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    11

    Default

    Quote Originally Posted by PhHein View Post
    Java Code:
    int current = ballArray[i];
    returns a Ball, not an int. Did I miss anything?
    No you didn't. I did.
    Not sure which int the OP want from the ball array. Perhaps they want an int property on the ball array (or ball in the array).
    Last edited by r035198x; 10-21-2009 at 03:29 PM. Reason: added (or ball in the array)

  5. #5
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    11

    Default

    Who knows? :shrug:
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  6. #6
    bert682 is offline Member
    Join Date
    Oct 2009
    Posts
    6
    Rep Power
    0

    Default

    Sorry if I wasnt clear at the start. Managed to get what I wanted by just adding into a for loop I have.

  7. #7
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    11

    Default

    You're still not making much sense, but that might be just me.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  8. #8
    [RaIdEn] is offline Senior Member
    Join Date
    Oct 2009
    Location
    California,US
    Posts
    201
    Rep Power
    9

Similar Threads

  1. Convert Char Array to String Array
    By Mayur in forum New To Java
    Replies: 8
    Last Post: 10-12-2009, 11:41 AM
  2. Array length and printing out uninitialized array.
    By nicolek808 in forum New To Java
    Replies: 4
    Last Post: 09-10-2009, 09:12 AM
  3. How to transfer 1D array in JAVA to 3D array in C
    By fishwater00 in forum New To Java
    Replies: 0
    Last Post: 07-31-2009, 06:24 PM
  4. Replies: 1
    Last Post: 03-31-2009, 06:40 AM
  5. String array to byte array?!
    By Joe2003 in forum Advanced Java
    Replies: 5
    Last Post: 02-28-2009, 06:09 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
  •