hi guys. I have an array item with 5 strings in it. I want to have it so if a person inputs one of the strings, java recogize that the input belongs in that array and removes it. (something like, if input = arrayitem, array = array - input). Can anyone point me in the right direction?
You can either set it to null or create a new array with that particular string removed.
I personally would prefer using a List instead of an array*
*Check out the Arrays class for a method which will create and return a List from your array
thanks guys, you both sent me on the right path. However, when i set it to null it prints out the word null so obviously i am dong that wrong, and how would i go about creating a new list without that item? it wont let me use -= char1.item[counter].
brent carterHowever, when i set it to null it prints out the word null so obviously i am dong that wrong...[counter wrote:.
Check out the source code for String#valueOf(Object obj) for the solution to that mystery !
In case you didn't know, search for a file called src.zip under your JDK_HOME. That contains the source code for the Java library classes.
brent carter ........... and how would i go about creating a new list without that item? it wont let me use -= char1.item[counter wrote:.
Create the list from the array and then remove the List elements as and when required.
Joined: Dec 15, 2011
thanks guys...heres my progress and everything seems to work