JVM does stack allocation whenever it is possible, you can learn about this by googling "escape analysis".