Solved Object[1+]

Discussion in 'Plugin Development' started by Anrza, Aug 23, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Anrza

    I'm wondering if it's possible to choose a few objects from an array to use, like String[1-4] or something, where you use strings 1 to 4, or if I'll have to use a more complicated way of doing it, like getting the length of the array and using a for-loop for the objects I want.

    I'm pretty sure there's an answer somewhere on the web, but I have actually no idea what to search for.
     
  2. Offline

    mine-care

    For is easy and not complicated
     
  3. Offline

    JWhy

    Right that.
    Code:java
    1. //print items 1 to 4 (inclusively)
    2. for(int i=1; i<=4; i++){
    3. System.out.println(items[ i].toString());
    4. }
     
  4. Offline

    Anrza

    mine-care
    It's easy, but nowhere near as easy as Object[x-y].

    JWhy That's the simplest solution?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  5. Offline

    mine-care

    This is a array, for is mostly used in arraylist.
    In String[] you do string[1]
    In arraylist you do arraylist.get(1);
     
  6. Offline

    Anrza

    You know, I'll just assume that you can't do what I wanted to do.
     
  7. Offline

    Hoolean

    Anrza

    If you are using a List Object, then you can use the subList method but if you are just using a plain Array, then there is no fancy method to do it for you. :)
     
    Anrza likes this.
  8. Offline

    mine-care

    Hoolean explained it perfectly... :eek:
    Thanks
     
Thread Status:
Not open for further replies.

Share This Page