91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

java javabean和List存儲表格數據(用List存儲類)

發布時間:2020-07-15 19:46:12 來源:網絡 閱讀:586 作者:wx5d21d5e6e5ab1 欄目:編程語言

javabean
一個具有完整的set和get方法,還有一個空構造器的類

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來存儲類,類來存儲數據

public  class test {

//表格每一行用Map來存儲,整個表格用list來存儲,即List內存的是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<User> list=new ArrayList<>();

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

}

//完整的javabean要有完整的set和get方法,還要有空的構造器
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;
}

}

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

会理县| 太原市| 应城市| 逊克县| 库车县| 会理县| 江安县| 庆元县| 杭州市| 天峻县| 郸城县| 离岛区| 句容市| 英吉沙县| 仙游县| 肥乡县| 张家港市| 九寨沟县| 蓬安县| 中西区| 东乌| 仁布县| 九龙城区| 奇台县| 仪陇县| 渝中区| 普兰县| 新邵县| 海城市| 托克逊县| 儋州市| 永城市| 太康县| 历史| 丰宁| 高唐县| 九龙城区| 九寨沟县| 博野县| 崇仁县| 旬邑县|