Question

i want select value in the array

how?

this is my code:

String[] str = {"1Farzad","2abbas","3ali","4hasan","5ajjad"};

for (String s:str) {
    builder.append(s);
    builder.append(" ");
}

for example how select "3ali" with 2 index?

Was it helpful?

Solution

Try doing it like this.

str[2]

Also, seems like you want this kind of loop.

for (int i=0; i<str.length; i++) {
    String s = str[i];
    builder.append(s);
    builder.append(" ");
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top