概述
获取list有几条内容 通过循环取值 当i小于list.size时i加一
List<nrbean> li=new ArrayList<nrbean>();// po=null;
li=dd.chakan(data);
String jsonObject="";
///通过下面方法能取出list中想要的数值
for(int i=0;i<li.size();i++){
int id;
nrbean nb=li.get(i);
System.out.print("------------"+nb.getId());
// }
i表示当前是第几条list
将第i条内容赋给对象nb
nrbean nb=li.get(i);
在通过对象nb get nb中的内容
下面是nrbean
package bean;
import java.text.SimpleDateFormat;
public class nrbean {
private int chakancichu;
public int getChakancichu() {
return chakancichu;
}
public void setChakancichu(int chakancichu) {
this.chakancichu = chakancichu;
}
private String username;
private String nr;
private double latitude;//纬度
private double longitude;//经度
private String data;
private int id;
private String img;
public String getImg(){
return img;
}
public void setImg(String img){
this.img=img;
}
private String url;
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
//
private int jici;
private String hfdate;
private String hfusername;
private String hfopenid;
private String hfnr;
private String fatieopenid;
public String getFatieopenid() {
return fatieopenid;
}
public void setFatieopenid(String fatieopenid) {
this.fatieopenid = fatieopenid;
}
public String getHfnr(){
return hfnr;
}
public void setHfnr(String hfnr){
this.hfnr=hfnr;
}
public int getJici() {
return jici;
}
public void setJici(int jici) {
this.jici = jici;
}
public String getHfdate() {
return hfdate;
}
public void setHfdate(String hfdate) {
this.hfdate = hfdate;
}
public String getHfusername() {
return hfusername;
}
public void setHfusername(String hfusername) {
this.hfusername = hfusername;
}
public String getHfopenid() {
return hfopenid;
}
public void setHfopenid(String hfopenid) {
this.hfopenid = hfopenid;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getNr() {
return nr;
}
public void setNr(String nr) {
this.nr = nr;
}
public double getLatitude() {
return latitude;
}
public void setLatitude(double latitude) {
this.latitude = latitude;
}
public double getLongitude() {
return longitude;
}
public void setLongitude(double longitude) {
this.longitude = longitude;
}
}
最后
以上就是文静钢笔为你收集整理的java通过for循环获取list中想要的内容的全部内容,希望文章能够帮你解决java通过for循环获取list中想要的内容所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复