Home > Back-end >  Ask how to make a list of each line into a String? thank you
Ask how to make a list of each line into a String? thank you

Time:05-17

I did this, but I wonder, why do I clearly defined is a LIST of type String, out of the iteration is not a String, and + "" around?
Thank you
List Testlist=new ArrayList (a);
For (Iterator I=testlist. The Iterator (); I.h asNext ())
{
String STR=(i.n ext () + "");
}

CodePudding user response:

The Iterator is not defined as of type String, wrote
List Testlist=new ArrayList (a);
For (Iterator I=testlist. The iterator (); I.h asNext ())
{
String STR=i.t ext ();
}

CodePudding user response:

refer to the original poster oracleperl response:
I did this, but I am strange, why do I clearly defined is a LIST of type String, out of the iteration is not a String, and + "" around?
Thank you
List Testlist=new ArrayList (a);
For (Iterator I=testlist. The Iterator (); I.h asNext ())
{
String STR=(i.n ext () + "");
}

You don't specify the generic type of Iterator
List Testlist=new ArrayList (a);
For (Iterator I=testlist. The iterator (); I.h asNext ())
{
String STR=i.n ext ();
}
  • Related