0

Hi, I am new to Java and am doing this as an on the side project.

I have an ArrayList of Strings. I want access each individual String and then do something with that string recursively.

However I used the Tokenizer to get the Strings and put them into arrays, so everything is under static void main method and I cannot implement another method unless its outwith the static void main method..

I need help taking each String from the List and comparing each character in the String inside my static void main method.

*Code is at home(at work) will post later if needed*

Thanks.

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by kvass
0

I'm not really sure what you are trying to do, but one thing that might help you is a for-each loop. The syntax is as follows:

for (One instance of a type : A collection of that type)
{
    //Iterate through the list.
}

For example,

ArrayList<String> arr = new ArrayList<String>();
//pretend arr is initialized to contain a bunch of strings.

for (String s : arr)
{
    /* This code will be executed for every string contained in list arr,
     * and when arr contains no more strings
     * the for-each loop will automatically break.
     */
}

Edited by kvass: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.