Array declared and initialized in one line.

This commit is contained in:
jabyte 2018-05-18 11:04:20 +01:00 committed by GitHub
parent c2d37e99e1
commit 1d94492e29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 10 deletions

View File

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