amor amor - 6 months ago 23
Java Question

java get length of List but always got = 1

How to get length of list, when I try to println it I just got result = 1, even a value in it list is many.

This is my code:

for(int i=0;i<lisPpob.size(); i++){
// first code
System.out.println("param 1 = "+ lisPpob.get(i).getLBRAP2T());

//secount code
List<String> lis= Arrays.asList(lisPpob.get(i).getLBRAP2T());
System.out.println("length = " + lis.size());
}


in first code I get :

param 1 = 986, 5785, 57, 675, 57


in the second code I get :

length = 1

Answer

You seem to have a string that you need to split..

System.out.println("length = "+ lisPpob.get(i).getLBRAP2T().split(", ").length);