package base.taxt;
import java.util.Arrays;
class Clothes{
String color;
char size;
Clothes(String color,char size ){
this.color=color;
this.size = size;
}
}
public class array {
public static void main(String[] args) {
Clothes[] frist = {new Clothes("red", 'M'), new Clothes("blue", 'S')};
Clothes[] second = {new Clothes("blue", 'S')};
Clothes[] third = new Clothes[frist.length];
for (int i = 0; i < frist.length; i++) {
//这个是最基础的打印方法.
Clothes copy = new Clothes(frist[i].color,frist[i].size);
third[i]=copy;
}
//打印数组中的东西的方法
//toString不支持String
System.out.println(second[0].color);
System.out.println(third[0].color);
System.out.println(Arrays.toString(third));
//输出的是地址
}
}
07-18
355
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
01-12
1840
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)