Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: get from Array

  1. #1
    New Coder
    Join Date
    Aug 2008
    Posts
    19
    Thanks
    5
    Thanked 0 Times in 0 Posts

    get 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.

    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;
    Code:
    int current = Array.getInt(ballArray,i);
    but it doesn't.

    Any ideas?

    Thanks

  • #2
    Senior Coder ckeyrouz's Avatar
    Join Date
    Jun 2009
    Location
    Montreal, Canada
    Posts
    1,044
    Thanks
    5
    Thanked 179 Times in 179 Posts
    The array ballArray contains elements of type Ball but not of type int.
    What you are trying to do is getting ints out of that array which is not possible.

    You can do this if you want:
    Code:
    Ball ball = (Ball) Array.get(ballArray,i);
    Software and cathedrals are much the same - first we build them, then we pray.

  • #3
    New Coder
    Join Date
    Aug 2008
    Posts
    19
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Managed to solve it by just using a for loop. Thanks for the help.


  •  

    Tags for this Thread

    Posting Permissions

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