This is just a short example of Go code:
package main
import "fmt"
func main() {
defer fmt.Println("world") //use of keyword 'defer'
fmt.Println("hello")
}
I am finding an equivalent of 'defer' in Java.
Instead of 'defer' I can use
try {
//do something
} finally {
//code using defer
}
Is there any alternative without using try/catch/finally?