hello world in java
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
Explanation:
- package main
: Defines that this file is part of the main
package, which is necessary for an executable Go program.
- import "fmt"
: Imports the fmt
package, which contains functions for formatting input and output.
- func main() { ... }
: Defines the main
function, which is the entry point of the program.
- fmt.Println("Hello, World!")
: Calls the Println
function from the fmt
package to print "Hello, World!" to the standard output (console).