ArrayList<DataType> myArrList = new ArrayList<DataType>();
ArrayList<String> myArrList = new ArrayList<String>(); myArrList.add("Belgium"); myArrList.add("France"); myArrList.add("Italy"); myArrList.add("Germany");
myArrList.size();
for (int i = 0; i < myArrList.size(); i++) { // myArrList.get(i)) }
for (String temp : myArrList) { //temp; }
if (myArrList.contains("Italy")) { // Already member }
package com.java.myapp; import java.util.ArrayList; public class MyClass { public static void main(String[] args) { String country = "Belgium,France,Italy,Germany,Spain"; String[] arr = country.split(","); ArrayList<String> arrList = new ArrayList<String>(); for(String a:arr) { arrList.add(a); } for(int i=0; i<arrList.size(); i++) { System.out.println("arrList index["+i+"] = " + arrList.get(i)); } System.out.println("========================================"); for (String temp : arrList) { System.out.println(temp); } } }
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท