java打印数组和数组长度

2019年2月13日22:40:05 发表评论 1,056 views
/**
 * Created by xabcd on 2019/2/13.
        */
public class java_yiweishuzu
{public static void main(String args[])
{
    int i;
    int a[]={5,6,8};//声明数组a并赋值
    for (i = 0;i<a.length;i++)
        System.out.print("a{"+i+"}="+a[i]+",\t");
    System.out.println("\n数组长度是:"+a.length);

}
}





a{0}=5, a{1}=6, a{2}=8, 
数组长度是:3

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: