真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

javajavabean和List存儲(chǔ)表格數(shù)據(jù)(用List存儲(chǔ)類)

javabean
一個(gè)具有完整的set和get方法,還有一個(gè)空構(gòu)造器的類

專注于為中小企業(yè)提供網(wǎng)站設(shè)計(jì)、網(wǎng)站建設(shè)服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)河池免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了數(shù)千家企業(yè)的穩(wěn)健成長(zhǎng),幫助中小企業(yè)通過(guò)網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。

class User{
    private int id;
    private double salary;
    private String name;
    private String hiredate;
    public User()
    {

}

public User(int id, double salary, String name, String hiredate) {
    super();
    this.id = id;
    this.salary = salary;
    this.name = name;
    this.hiredate = hiredate;
}

public int getId() {
    return id;
}
public void setId(int id) {
    this.id = id;
}
public double getSalary() {
    return salary;
}
public void setSalary(double salary) {
    this.salary = salary;
}
public String getName() {
    return name;
}
public void setName(String name) {
    this.name = name;
}
public String getHiredate() {
    return hiredate;
}
public void setHiredate(String hiredate) {
    this.hiredate = hiredate;
}

public String toString()
{
    return "id:"+id+"salary:"+salary+"name:"+name+"hiredate:"+hiredate;
}

}

思路:用List來(lái)存儲(chǔ)類,類來(lái)存儲(chǔ)數(shù)據(jù)

public  class test {

//表格每一行用Map來(lái)存儲(chǔ),整個(gè)表格用list來(lái)存儲(chǔ),即List內(nèi)存的是Map
public static void main(String[]args)
{

User user1=new User(1001,11,"張三","2018.5.5");
User user2=new User(1002,10,"張三2","2018.5.52");
User user3=new User(1003,9,"張三3","2018.5.53");
List list=new ArrayList<>();

list.add(user1);
list.add(user2);
list.add(user3);
    for(User v:list)
    {   
        System.out.println(v);
    }
Map map=new HashMap<>();
map.put(1, user1);
map.put(2, user2);
map.put(3, user3);
Set key=map.keySet();
for(Integer i:key)
{
    System.out.println(map.get(i));
}
}

}

//完整的javabean要有完整的set和get方法,還要有空的構(gòu)造器
class User{
private int id;
private double salary;
private String name;
private String hiredate;
public User()
{

}

public User(int id, double salary, String name, String hiredate) {
    super();
    this.id = id;
    this.salary = salary;
    this.name = name;
    this.hiredate = hiredate;
}

public int getId() {
    return id;
}
public void setId(int id) {
    this.id = id;
}
public double getSalary() {
    return salary;
}
public void setSalary(double salary) {
    this.salary = salary;
}
public String getName() {
    return name;
}
public void setName(String name) {
    this.name = name;
}
public String getHiredate() {
    return hiredate;
}
public void setHiredate(String hiredate) {
    this.hiredate = hiredate;
}

public String toString()
{
    return "id:"+id+"salary:"+salary+"name:"+name+"hiredate:"+hiredate;
}

}


分享名稱:javajavabean和List存儲(chǔ)表格數(shù)據(jù)(用List存儲(chǔ)類)
文章源于:http://weahome.cn/article/pcggoe.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部