Java案例:参数化类型数组
【摘要】
package net.hw.generic; import java.time.LocalDate; /** * Created by howard on 2018/1/31. */public class GenericDemo01 { public static void main(String[] args) { ...
-
package net.hw.generic;
-
-
import java.time.LocalDate;
-
-
/**
-
* Created by howard on 2018/1/31.
-
*/
-
public class GenericDemo01 {
-
public static void main(String[] args) {
-
Test<String>[] test1 = new Test[3];
-
test1[0] = new Test<>();
-
test1[0].setData("howard");
-
test1[1] = new Test<>();
-
test1[1].setData("smith");
-
test1[2] = new Test<>();
-
test1[2].setData("alice");
-
-
for(int i = 0; i < test1.length; i++) {
-
System.out.println(test1[i]);
-
}
-
-
System.out.println();
-
-
Test<LocalDate>[] test2 = new Test[3];
-
test2[0] = new Test<>();
-
test2[0].setData(LocalDate.of(2017, 12, 20));
-
test2[1] = new Test<>();
-
test2[1].setData(LocalDate.of(2018, 1, 24));
-
test2[2]
文章来源: howard2005.blog.csdn.net,作者:howard2005,版权归原作者所有,如需转载,请联系作者。
原文链接:howard2005.blog.csdn.net/article/details/79335660
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)