集合中装载对象和基本类型的小问题
来源:互联网 发布:银行家算法代码实现 编辑:程序博客网 时间:2024/06/06 11:42
// ======================================装载基本类型==========================================================//List list = new ArrayList();for (int i = 0; i < 10; i++) {int t = 10;list.add(t + i);t = 0;System.out.println("基本类型int当前值为:" + t);}System.out.println("--------------------------");for (int m = 0; m < list.size(); m++) {System.out.println("list最终装载的基本类型int值为:" + list.get(m));}// =====================================装载对象==========================================================//List<Test> list = new ArrayList<Test>();for (int i = 0; i < 10; i++) {Test test = new Test();test.setId(i);list.add(test);test.setId(0);System.out.println("test当前值为:" + test.getId());}System.out.println("--------------------------");for (int m = 0; m < list.size(); m++) {System.out.println("list最终装载的test值为:" + list.get(m).getId());}}}class Test {private int id;public void setId(int id) {this.id = id;}public int getId() {return this.id;}}
运行结果为:
装载基本类型:
基本类型int当前值为:0
基本类型int当前值为:0
基本类型int当前值为:0
基本类型int当前值为:0
基本类型int当前值为:0
基本类型int当前值为:0
基本类型int当前值为:0
基本类型int当前值为:0
基本类型int当前值为:0
基本类型int当前值为:0
--------------------------
list最终装载的基本类型int值为:10
list最终装载的基本类型int值为:11
list最终装载的基本类型int值为:12
list最终装载的基本类型int值为:13
list最终装载的基本类型int值为:14
list最终装载的基本类型int值为:15
list最终装载的基本类型int值为:16
list最终装载的基本类型int值为:17
list最终装载的基本类型int值为:18
list最终装载的基本类型int值为:19
装载对象:
test当前值为:0
test当前值为:0
test当前值为:0
test当前值为:0
test当前值为:0
test当前值为:0
test当前值为:0
test当前值为:0
test当前值为:0
test当前值为:0
--------------------------
list最终装载的test值为:0
list最终装载的test值为:0
list最终装载的test值为:0
list最终装载的test值为:0
list最终装载的test值为:0
list最终装载的test值为:0
list最终装载的test值为:0
list最终装载的test值为:0
list最终装载的test值为:0
list最终装载的test值为:0
- 集合中装载对象和基本类型的小问题
- Spring配置中出现的基本类型和集合
- java基本类型的对象类型在集合的判断
- Spring、基本类型属性和集合类型属性的注入
- Javascript中判断对象的基本类型
- Javascript中判断对象的基本类型
- 关于java的一些小问题,list中添加对象,java基本数据类型对象
- SQLLDR装载换行符的小问题
- 类型的装载连接和初始化
- (集合和引用类型、基本数据类型赋值不一样)一个简单的java问题 先后的赋值问题
- 对于集合内装载的对象数据进行自定义排序 !
- 基本引用类型和对象引用类型的区别
- c#中常用的集合类型及基本用法
- 对象的装载和实例化
- 集合的小问题
- Java中关于Json对象类型和字符串类型之间互相转化的问题
- Java中关于Json对象类型和字符串类型之间互相转化的问题 .
- java对象和基本类型
- mars老师推荐的学习android路线
- iOS 截屏功能代码
- 镜像网站
- unsigned int nMsgType:8
- ANDROID 为LISTVIEW构造自定义布局
- 集合中装载对象和基本类型的小问题
- 男女用户的不同偏好:扩展型和维护型游戏
- 虚拟机学习总结
- 文档型数据库MongoDB总结
- ora-12514监听程序当前无法识别连接描述符中请求的服务
- OpenCV下的直线拟合
- Android SDK Tools Revision 13 发布
- 里面link的media=”screen”意思
- C++对象中的私有成员变量也可以被访问