The statements below shows the declaration of an array:
String[] Municipality ={”Steve Tshwete”, “Nkomazi”, “City of Mbombela”, “Govan Mbeki”};
1) Make use of a loop of your choice and write statement(s) that will display all array elements indicating the Municipality’s name starting from:
Municipality 1: Steve Tshwete
Municipality 2: Nkomazi
etc
public class Main
{
public static void main(String[] args) {
String[] Municipality ={"Steve Tshwete", "Nkomazi", "City of Mbombela", "Govan Mbeki"};
for(int i=0;i<4;i++){
System.out.println("Municipality "+(i+1)+": "+Municipality[i]);
}
}
}
Comments
Leave a comment