基本資料結構
串列(List)
Java https://docs.oracle.com/javase/8/docs/api/java/util/List.html
import java.util.*;
public class ListExample{
public static void main(String args[]){
List<String> al=new ArrayList<String>();
List<Integer> numbers = Arrays.asList(1, 2, 3);
al.add("Amit");
al.add("Vijay");
al.add("Kumar");
al.add(1,"Sachin");
System.out.println("Element at 2nd position: "+al.get(2));
for(String s:al){
System.out.println(s);
}
}
}
Go https://golang.org/pkg/container/list/
package main
import (
"container/list"
"fmt"
)
func main() {
// Create a new list and put some numbers in it.
l := list.New()
e4 := l.PushBack(4)
e1 := l.PushFront(1)
l.InsertBefore(3, e4)
l.InsertAfter(2, e1)
// Iterate through list and print its contents.
for e := l.Front(); e != nil; e = e.Next() {
fmt.Println(e.Value)
}
}
//list
//list