JAVA中List的Add方法问题

qiaotongzxcv 2014-07-19 11:47:53
List<NewMapTab> pointslist = new ArrayList<NewMapTab>();
while(rs.next())
{
NewMapTab MapPoint = new NewMapTab();
//System.out.println(rs.getString(1));
MapPoint.setID(rs.getString(1));
MapPoint.setNAME(rs.getString(2));
MapPoint.setLAT(rs.getFloat(3));
MapPoint.setLON(rs.getFloat(4));
pointslist.add(MapPoint);
}
输出pointslist中的值显示结果为com.testaction.dao.NewMapTab@1081d2e
...全文
400 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
Lelouch_Lamperouge 2014-07-29
  • 打赏
  • 举报
回复
这。。。。。。
  • 打赏
  • 举报
回复
重写NewMapTab 的tostring方法
Mr-BUG 2014-07-29
  • 打赏
  • 举报
回复
List<NewMapTab> pointslist = new ArrayList<NewMapTab>(); pointslist集合存的就是NewMapTab类型的对象,所以你输出pointslist集合当然输出com.testaction.dao.NewMapTab@1081d2e啊,这个就是pointslist对象
大头爱放假 2014-07-29
  • 打赏
  • 举报
回复
pointslist.add(MapPoint); 你在pointslist中add的是对象~ 所以输出的也是对象, 应该先获得其中的对象,然后打印对象的属性值才对
Richardkaola 2014-07-29
  • 打赏
  • 举报
回复
你的list里面存的是引用类型,直接用System.out.println(object);输出引用当然得到的是你上面贴出来的 结果
wavky 2014-07-25
  • 打赏
  • 举报
回复
不理解楼主想问的是什么问题,你要重写NewMapTab中的toString方法才能输出比较直观的内容啊
  • 打赏
  • 举报
回复

for (NewMapTab n : pointslist ) {
    System.out.print(n.getId() + "  ");
    System.out.print(n.getNAME() + "  ");
    System.out.print(n.getLAT() + "  ");
    System.out.println(n.getLON());
}
  • 打赏
  • 举报
回复

for (NewMapTab n : pointslist ) {
    System.out.print(n.getId() + "  ");
    System.out.print(n.getNAME() + "  ");
    System.out.print(n.getLAT() + "  ");
    System.out.println(n.getLON());
}
save4me 2014-07-24
  • 打赏
  • 举报
回复
把你输出的代码贴一下,估计是你输出的代码本身有点问题
引用 4 楼 qiaotongzxcv 的回复:
回复三楼:lon是float型,不能把rs.getFloat(4)强转
qiaotongzxcv 2014-07-24
  • 打赏
  • 举报
回复
回复三楼:lon是float型,不能把rs.getFloat(4)强转
csdn_aspnet 2014-07-21
  • 打赏
  • 举报
回复
MapPoint.setLON(rs.getFloat(4));括号中rs.getFloat(4)这个toString一下
csdn_aspnet 2014-07-21
  • 打赏
  • 举报
回复
你装的是对象吧 你要输出对象中的属性
save4me 2014-07-19
  • 打赏
  • 举报
回复
Add方法没有什么问题,你输出值的代码是怎么样的?

50,526

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧