String 试图使用DataLoader类将字符串列表转换为整数列表,但它一直说整数列表为空?
这是我的String 试图使用DataLoader类将字符串列表转换为整数列表,但它一直说整数列表为空?,string,list,integer,String,List,Integer,这是我的DataLoader类,我试图使用这些方法在另一个类中转换我的列表,我知道输入不是null,但它说我的方法的输出是null。现在我已经把自己弄糊涂了,因为我盯着这个看得太久了:( 公共类数据加载器{ /**此方法将字符串数组列表转换为整数列表 *@param输入 *@返回 */ 公共静态列表IntLoader(ArrayList输入){ List newList=newarraylist(); for(字符串s:输入) { newList.add(Integer.valueOf(s))
DataLoader
类,我试图使用这些方法在另一个类中转换我的列表,我知道输入不是null
,但它说我的方法的输出是null
。现在我已经把自己弄糊涂了,因为我盯着这个看得太久了:(
公共类数据加载器{
/**此方法将字符串数组列表转换为整数列表
*@param输入
*@返回
*/
公共静态列表IntLoader(ArrayList输入){
List newList=newarraylist();
for(字符串s:输入)
{
newList.add(Integer.valueOf(s));
}
返回newList;
}
/**此方法将字符串数组列表转换为双列表
*@param输入
*@返回
*/
公共静态列表双加载器(ArrayList输入){
List newList=newarraylist();
for(字符串s:输入)
{
newList.add(Double.valueOf);
}
返回newList;
}
}
public class DataLoader {
/** this method converts string array list to integer list
* @param input
* @return
*/
public static List<Integer> IntLoader(ArrayList<String> input) {
List<Integer> newList = new ArrayList<Integer>() ;
for (String s : input)
{
newList.add(Integer.valueOf(s));
}
return newList;
}
/** this method converts string array list to double list
* @param input
* @return
*/
public static List<Double> DoubleLoader(ArrayList<String> input) {
List<Double> newList = new ArrayList<Double>() ;
for (String s : input)
{
newList.add(Double.valueOf(s));
}
return newList;
}
}