【Java开源代码栏目提醒】:网学会员,鉴于大家对Java开源代码十分关注,论文会员在此为大家搜集整理了“ArrayTest2.java”一文,供大家参考学习!
public class ArrayTest2
{
public static void main(String arg[])
{
int[] counts = new int[10];
String names[] = new String[10];
double numbers[][] = new double[10][10];
People people[] = new People[10];
for(int i=0; i<10; i++)
{
counts[i] = i;
names[i] = new String("name_"+i);
for(int j=0; j<10; j++)
{
numbers[i][j] = ((double)i)/j;
}
people[i] = new People("people_" + i);
}
System.out.println(counts[1]);
System.out.println(names[4]);
System.out.println(numbers[3][4]);
System.out.println(people[2]);
}
}
class People
{
String name = "";
int age;
String company = "";
public People(String name)
{
this.name = name;
}
public People()
{
age=0;
}
public String toString()
{
return name;
}
}
/*
result:
0
null
0
null
*/
上一篇:
ArrayTest1.java
下一篇:
多年来只想说一句,我不怪你