这个循环应该怎么写?!

labimantou 2002-12-29 03:15:35
Iterator it = c.iterator();
while(it.hasNext()){
if (((Card)it.next()).x <=tx && y <= (((Card)it).y + Card.width) {……}
}
next()是取到下一个元素,我用了这个元素的((Card)it.next()).x 值,
但是我还想取属性y的值该怎么写?((Card)it).y这样写出错!!!!

谢谢
...全文
12 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaofenguser 2002-12-29
  • 打赏
  • 举报
回复
Card cd=(Card)it.next();
再用cd.x和cd.y

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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