Noob Question

Discussion in 'Plugin Development' started by Hoolean, Aug 28, 2012.

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

    Hoolean

    Hi guys, sorry to be Nooby :oops: but what is the bukkit alternative to java lists?
     
  2. Offline

    sternmin8or

    java lists still... bukkit isnt its own language. All of java still applies to bukkit.
     
  3. Offline

    Hoolean

    I know that, it's just I'm sure I saw somewhere that it was best to use another way...
     
  4. Offline

    sternmin8or

    It depends on what you are doing. Arrays and lists have unique characteristics, as do hashmaps and all sub-categories of arrays/lists.
     
  5. Offline

    Hoolean

    How do arrays work? Example maybe?
     
  6. Offline

    sternmin8or

    arrays are simple data types. They are mutable, however their length is not
    int[] array = new int[4]; creates a new empty array of ints . To set an int its as simple as:
    array[0] = 5
    System.out.println(array[0]); will obviously be 5
    thats pretty much all there is to it

    edit: heres a more in depth description:http://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html

    you might want to google the advantages of arrays over ArrayLists and vice versa
     
  7. Offline

    Hoolean

    Is there a way to add entities to a list without turning them into a string and stuff
     
  8. Offline

    sternmin8or

    I don't think there is a data type that CANT do that. Just be aware that storing large amounts of entities repeatedly/for extended periods of time is bad habit.
    Example: ArrayList<Entity> or Entity[]
     
  9. Offline

    Firefly

    List<Entity> ents = new ArrayList<Entity>();

    EDIT: ninja'd :/
     
  10. Offline

    Hoolean

    Thank you, I'll try that. :D
     
  11. Offline

    honestduane

  12. Offline

    Hoolean

    ^ ^
    | Tried That |

    Eclipse gave me errors...

    Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be
    parameterized:

    Code:
    successfullEntities.add(entity);
    - Type mismatch: cannot convert from element type Object to
    Entity:


    Code:
    for(Entity sE : successfullEntities) {


    EDIT: It has now stopped showing errors after save :? (<-- New smiley)

     
Thread Status:
Not open for further replies.

Share This Page