Syntax for switch-case in Java -


i'm using switch case in java first time , i'm bit unsure syntax. assuming setteamname function works, does, following function make of teams in array have placeholder string it's name or should case 0: since starts @ 0?

public static team[] maketeams(){     team[] teams = new team[10];     for(int = 0; < teams.length; i++){         switch(i){             case 1: teams[0].setteamname("arsenal");             case 2: teams[1].setteamname("arsenal");             case 3: teams[2].setteamname("arsenal");             case 4: teams[3].setteamname("arsenal");             case 5: teams[4].setteamname("arsenal");             case 6: teams[5].setteamname("arsenal");             case 7: teams[6].setteamname("arsenal");             case 8: teams[7].setteamname("arsenal");             case 9: teams[8].setteamname("arsenal");             case 10: teams[9].setteamname("arsenal");         }     }     return teams; } 

use break statement after every instruction in case.


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -