有空可以看看,
不知能不能超越JAVA的作法。
hello.go
package main import "fmt" func main() { s := "hello" m := " world" a := s + m b := [...]int{4, 5, 6, 7,8} var ar = [10]byte {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'} var c, d []byte c = ar[2:5] d = ar[3:5] numbers := make(map[string] int) numbers["one"] = 1 numbers["two"] = 10 numbers["three"] = 3 x := 12 if x > 10 { fmt.Println("x is greater than 10") } else { fmt.Println("x is less than 10") } sum := 0; for index:=0; index<10;index++ { sum += index } fmt.Println("sum is equeal to ", sum) fmt.Printf("%d\n", numbers["three"]) fmt.Printf("%d\n", c) fmt.Printf("%d\n", d) fmt.Printf("%s\n", a) fmt.Printf("The first element is %d\n", b[0]) }