【发布时间】:2012-10-17 05:42:21
【问题描述】:
我已经设法从数据库中获取一个字符串,并能够将它的一些元素存储在变量中,以减少应用程序与数据库交互的次数。但是,我希望从数据库中获取第一个元素并将其存储在列表中,但是当我将字符串解析为新列表时,它会不断产生错误。请帮忙
//String fetched from the database
final String[] rec = split(myresult,seperator);
//loc is the first String to be parsed to a String..
//desc is the 2nd string to be parsed to a textarea
//coords 3rd string which contains coordinates..
String loc=rec[0];
final String desc=rec[1];
String coords=rec[2];
//ERROR IS GENERATED HERE!!!
listmboya=new List(loc);
//Separate the coordinates in the string...
String seperator2=",";
String [] coordinates=split(coords,seperator2);
String lat=coordinates[0];
String lot=coordinates[1];
//convert them to floats..
item1=Float.parseFloat(lat);
item2=Float.parseFloat(lot);
【问题讨论】: