import java.util.ArrayList;
import java.util.List;
public class CollectionsDemo {
public static void main(String[] args) {
List list = CollectionsDemo.getStudentList();
for (int i = 0; i < list.size(); i++) {
System.out.println(((Student) list.get(i)).getID());
}
}
private static List getStudentList() {
List list = new ArrayList();
list.add(new Student(1));
list.add(new Student(2));
return list;
}
}
class Student {
int id;
Student(int id) {
this.id = id;
}
public int getID() {
return this.id;
}
}
Javascript version,
You can use array.pop() to remove elements.
<html>
<head>
<script language = "javascript">
var array = [];
array.push(1);
array.push(1);
array.push(1);
</script>
</head>
<body>
<script language = "javascript">
alert(array.length);
</script>
</body>
</html>
行程安排應用程式
沒有留言:
張貼留言