Apr 9

java 基本类型和数组类型赋值方法 不指定

ljh , 10:18 , JAVA SSH学习 , 评论(0) , 引用(0) , 阅读(1256) , Via 本站原创 | |
基本数据类型数组直接赋值
如int [] arr = new int[3];
arr[0]=1;
arr[1]=2;
arr[2]=3;
也可以初始化int [] arr={1,2,3};

引用数据类型
String [] strArr = new String[3];
strArr[0]=new String("a");
strArr[1]=new String("b");
strArr[2]=new String("c");
也可以
String [] strArr={"a","b","c"};

String 类型的对象有length()方法
String[] 数组类型有length 属性
Tags:
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]