我想知道是否有可能將Object
轉換成別的東西。Java - Casting,仿製藥,對象和陣列
我有一個對象,其中包含一系列數字以隨機順序排列,如:3,4,2,5,1,並且想知道我是否可以將它變成int []或從中選擇某些元素,如從序列中的數字?
編輯: 所以一些代碼,我的是:
//This contains all the different combinations of the numbers
ArrayList routePop4 = new ArrayList();
//This picks out the first one, just as a test
Object test = routePop4.get(0);
但這個想法是,我想通過測試的每個元素循環。
**它是如何包含這些數字的?給我們一些代碼。 –
一個實際的例子可以幫助你很多。 – Lion
添加了一些代碼 –