Array declared and initialized in one line.
@@ -8,15 +8,7 @@ import org.springframework.web.bind.annotation.GetMapping;
public class ThymeleafArrayController {
@GetMapping("/arrays")
public String arrayController(Model model) {
- String[] continents = new String[7];
-
- continents[0] = "Africa";
- continents[1] = "Antarctica";
- continents[2] = "Assia";
- continents[3] = "Australia";
- continents[4] = "Europe";
- continents[5] = "North America";
- continents[6] = "Sourth America";
+ String[] continents = {"Africa", "Antarctica", "Asia", "Australia", "Europe", "North America", "Sourth America"};
model.addAttribute("continents", continents);
