创建的对象的ArrayList [英] Creating an Arraylist of Objects

查看:121
本文介绍了创建的对象的ArrayList的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,现在我已经找到了如何正确地进行多次同一个对象,我需要知道如何让他们的阵列,改变取决于需要多少,因为它是pretty的太多了对象,其存储3个号码。我怎样才能创建一个ArrayList是不同的对象,因为我将不得不在他们里面的数字不同

解决方案

 的ArrayList<矩阵>名单=新的ArrayList<矩阵>();
list.add(新矩阵(1,1,10));
list.add(新矩阵(1,2,20));
 

So, now I've figured out how to make multiple of the same object correctly, I need to know how to make an array of them, changing depending on how many are needed, because it is pretty much an object, that stores 3 numbers. How can I Create an arraylist that is of different objects, because I'm going to have the numbers inside them different

解决方案

ArrayList<Matrices> list = new ArrayList<Matrices>();
list.add( new Matrices(1,1,10) );
list.add( new Matrices(1,2,20) );

这篇关于创建的对象的ArrayList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆