arrays - How do I find a String list's length in Java? -


i'm new java, , i'm i'm not using lists properly, i'm saving loads of user input responses elements of string list (as side question, want string list or array list task?), , later want print out these elements @ end of program. however, want automatically through loop, don't know length of list make loop job. tried

for(int j = 0; j <= (results.length-1); j++){ 

where "results" name of string list, it's giving me error "cannot find symbol." there way length of string list in java? , using list thing properly, or should trying array list instead? appreciated.

if, length, mean total number of elements contained in list, can use size() method. returns integer specifies number of elements present in list.

as for loop, can this:

for (int j = 0; j < results.size(); j++) { //write loop logic here } 

Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -