📄 collectiondemo.java
字号:
//CollectionDemo.java
import java.util.*;
public class CollectionDemo
{
public static void main( String[] args )
{
String strMonths[]={
"一月","二月","三月",
"四月","五月","六月",
"七月","八月","九月",
"十月","十一月","十二月"
};
//get count of months
int nMonthLen= strMonths.length;
//create arrayList object
Collection months= new ArrayList();
//pub months value to arraylist object
for( int i=0; i< nMonthLen; i++){
months.add(strMonths[i]);
}
//print all element in arraylist
Object s[] = months.toArray();
for( int i=0; i< s.length; i++ ){
System.out.println(s[i].toString());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -