数组01

public class Test {
    public static void main(String arg[]){
        int[] a={2,4,6,8,10};
        for (int i=0;i<a.length;i++)
        {
            System.out.println(a[i]);
        }
        
        for (int i=0;i<arg.length;i++)
        {
            System.out.println(arg[i]);
        }        
    }
}

 

View Code
 1 import java.util.*;
 2 
 3 public class Test {
 4     public static void main(String arg[]){
 5         int [] s;
 6         s=new int[5];
 7         for (int i=0;i<5;i++)
 8         {
 9             s[i]=2*i+1;
10             System.out.println(s[i]);
11         }
12     }        
13 }

 

View Code
 1 class Date
 2 {
 3     int year,month,date;
 4     public Date(int y,int m,int d)
 5     {
 6         year=y;
 7         month=m;
 8         date=d;
 9     }
10     public String toString()
11     {
12         return Integer.toString(year)+" "+Integer.toString(month)+" "+Integer.toString(date);            
13     }
14 }
15 
16 public class Test {
17     public static void main(String arg[]){
18         Date[] NewDate;
19         NewDate=new Date[3];
20         for (int i=0;i<3;i++)
21         {
22             NewDate[i]=new Date(2005,11,i+1);
23             System.out.println(NewDate[i]);
24         }        
25     }        
26 }

 

posted @ 2013-04-08 14:01  glt66  阅读(141)  评论(0编辑  收藏  举报