0
why this loop is running only two times while taking input
import java.util.*; class Reverse { public static void main(String[] arr) { Scanner sc=new Scanner(System.in); int n=3; String[] lin=new String[n]; for(int i=0;i<3;i++){ lin[i]=sc.nextLine(); } for(int i=0;i<3;i++){ String[] revl=lin[i].split(" "); for(int j=revl.length-1;j>=0;j--) { System.out.print(revl[j]+" "); } System.out.println(); } } }
3 Answers
+ 2
Both of your for statements are increasing i. Try changing one of the i variables then it should run 9 times
+ 2
put a different counter variable in for your second for loop
0
thanks