Jump to content

ArrayList to string


Recommended Posts

Posted (edited)

Hey, my head just exploded. How can i pass this into a string for GroundItem? ex: GroundItem lewt = ("Huge turd", "Flashlight");

    public static ArrayList<String> GUILoot = new ArrayList<String>();

My arraylist outprints this atm:

 

[iNFO ][04/01/14 01:21:22 AM]: GUILoot: [Vial, Herb, Bones]

 

thanks!

 

Edited by daviyow
Posted

can i do that in my getState? cus i have some checks for loot in my state or where would be the past part to do this

Wherever you think would be best. Forgot an ArrayList returned the string with brackets though, so you can just pass them in easy and replace the characters you don't want.

GUILoot.toString().replace("[", "").replace("]", "");
Posted (edited)
public boolean lootOnGround(){
        GroundItem g;
        for (String s: GUILoot){
            g = closestGroundItemForName(s);
            if(g != null) return true;
        }
        return false;
    }

Or just closestGroundItemForName((String[])GUILoot.toArray()) to pass it as a whole

Edited by Ande
Posted

 

Wherever you think would be best. Forgot an ArrayList returned the string with brackets though, so you can just pass them in easy and replace the characters you don't want.

GUILoot.toString().replace("[", "").replace("]", "");

 

 

Is that ok to place this under dispose(); at GUI?

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...