码迷,mamicode.com
首页 > 其他好文 > 详细

exe

时间:2016-08-11 00:21:47      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:

package ArrayListT;

import java.util.ArrayList;
import java.util.Iterator;
/*import java.util.Scanner;*/
import java.util.Map.Entry;

public class ArrayListedTest{
    public static void main(String[] args) {
        /*String name = null;
        int id;
        int age;
        int i = 0;*/
    /*    Scanner input  = new Scanner(System.in);
        do {
            System.out.println("请输入学生学号:");
            id = input.nextLong();
            System.out.println("请输入学生姓名:");
            name = input.nextLine();
            System.out.println("请输入学生年龄:");
            age = input.nextInt();
            Student stu = new Student(id,name,age);
            i++;
        } while (id!= 0);*/
        int i = 0;
        ArrayList<Student> arraylist = new ArrayList<Student>();
        Student stu0 = new Student(1,"成龙",25);
        Student    stu1 = new Student(2,"张三",23);
        Student stu2 = new Student(3,"王五",24);
        arraylist.add(stu0);
        arraylist.add(stu1);
        arraylist.add(stu2);
        Iterator st = arraylist.iterator();
        while(st.hasNext()){
            Student stu  = arraylist.next();
            if(stu.getId() == 0){
                System.out.println("结束录入!");
                i = 0;
            }
            
        }
    }
    
}
package ArrayListT;

public class Student {
    private String name = null;
    private long id;
    private int age;
    int i ;

    private String[] stu;
    
    public Student() {
        super();
    }
    public Student(long id, String name, int age) {
        super();
        this.setName(name);
        this.setId(id);
        this.setAge(age);
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public long getId() {
        return id;
    }
    public void setId(long id) {
        this.id = id;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
    public String[] getStu() {
        return stu;
    }
    public void setStu(String[] stu) {
        this.stu = stu;
    }
    
}

 

exe

标签:

原文地址:http://www.cnblogs.com/xiaolei121/p/5759100.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!