14章试题

    xiaoxiao2022-06-30  63

    public class c { public int id; public String name; public int age; public int score; public void show1(){ System.out.println(id+" "+name+" "+age+" "+score); } } public class c1 { c[] st=new c[30]; public void show2(c stu){ for(int i=0;i<st.length;i++){ if(st[i]==null){ st[i]=stu; break; } } } public void show3(){ System.out.println("本班学生列表:"); for(int i=0;i<st.length;i++){ if(st[i]!=null){ st[i].show1(); } } System.out.println(); } } public class c2 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub c s=new c(); s.id=1; s.age=18; s.name="小米"; s.score=98; c s1=new c(); s1.age=18; s1.id=2; s1.name="小卡"; s1.score=99; c1 ss=new c1(); ss.show2(s); ss.show2(s1); ss.show3(); } }
    转载请注明原文地址: https://ju.6miu.com/read-1125932.html

    最新回复(0)