How to fetch the values from list, if list contains values as array in java -
how fetch values list, if list contains values array in java. example:
testlist = [[item 1, item 2, item 6]]
now size 1, while trying testlist.get(0);
output [item 1, item 2, item 6]
. fetch individual values like:
item 1, item 2, item 3
how this?
you can access list using .get(index)
:
list<string> list = new linkedlist<string>(); list.add("item 1"); system.out.println(list.get(0)); //item 1
you can access array using [index]
:
string[] array = new string[] {"item 1"}; system.out.println(array[0]); // item 1
and can access nested list/array, using right access operator(-concatenation):
list<string[]> list = new linkedlist<string[]>(); list.add(new string[] {"item 1"}); list.add(new string[] {"item 2"}); system.out.println(list.get(0)[0]); // item 1
java
No comments:
Post a Comment