我是初學者,所以這絕對是常識,所以我來這裏問。提高製作簡單陣列的效率
如果我想打一個很大的數組,只是包含不同的話,像這樣的
adjectives[0] = "one";
adjectives[1] = "two";
adjectives[2] = "three";
adjectives[3] = "four";
adjectives[4] = "five";
這只是一個小例子,我實際上使陣列是非常大的。當然,我不必對此進行硬編碼,並逐一完成每一行。我怎樣才能更有效地做到這一點?
編輯:
問題已經稍微轉移,而仍然在這個話題上。
我想打開一個txt文件這樣
甲
乙
Ç
d
Ë
到一個數組列表,其吐出由程序到控制檯,用於另一個程序。
基本上TextFile.txt的 - >程序 - > arraylist.txt
您使用循環。 – Eran
只需使用'for'循環。 –
對於動態大小,最好使用ArrayList。 – Blobonat