Created
July 12, 2018 15:20
-
-
Save hi-manshu/568658b968df9cd9430d1c6bfbd759f9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| //imported the package fmt | |
| import "fmt" | |
| func main() { | |
| // we have declared an array with name "nameArray" of size 2 and data-type integer | |
| var nameArray [2]string | |
| //we assigned value Himanshu to the first element in the array nameArray | |
| nameArray[0] = "Himanshu" | |
| //we assigned value Himanshu to the second element in the array nameArray | |
| nameArray[1] = "Singh" | |
| //Printing the elements in the array by accessing it by the position | |
| fmt.Println("First Name:", nameArray[0]) | |
| fmt.Println("Second Name:", nameArray[1]) | |
| } | |
| >>go run arrayExample.go | |
| >>First Name: Himanshu | |
| >>Second Name: Singh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment