+ 4
Please how can i get the below code to print two,three and five
public class Program { public static void main(String[] args) { int i=1; String [] one={"one","two"}; String [] two={"three","four"}; String [] three={"five","six"}; System.out.println(one[i]); if(i>=one.length-1){ i=0; System .out.println (two[i]); }else if(i>=two.length -1){ System .out.println (three[i]); }else{i++;} } }
1 ответ
+ 4
Musa Yushau Abu You can do like this.
int i = 1;
String [] one = {"one","two"};
String [] two = {"three","four"};
String [] three = {"five","six"};
System.out.println(one[i]);
if(i >= two.length - 1) {
i = 0;
System.out.println (two[i]);
}
i = 1;
if(i >= three.length - 1) {
i = 0;
System.out.println (three[i]);
}
But you can simply get like this:-
System.out.println (one[1]);
System.out.println (two[0]);
System.out.println (three[0]);