0

I need to know how to calculate the output by hand

public class Test { public static void main(String[] args) { int [ ] [ ] values = {{3, 4, 5, 1}, {33, 6, 1, 2}}; int v = values [0] [0]; for (int row = 0; row< values [1].length; row++) { for (int i = 1; i < values [1].length; i++) if (v < values [row] [i]; System.out.print(v + " "); } } }

28th Apr 2020, 4:09 AM
Izzuddin
Izzuddin - avatar
4 Respostas
+ 2
Please link any sources or your own code for reference. Or mention it on the description.
28th Apr 2020, 4:12 AM
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~ - avatar
+ 2
I think you're program is counting the elements in the two dimensional array that are less than or smaller than 3. If the elements of arrays are less than three, than 3 and a white space will be printed. So this program will print 3 3 3.Beacuse there are 3 elements that are smaller than 3 likewise 1,1 and 2 are the small numbers than 3. There is error in the code the row should be the length of the array. This is the right code for your solution, class Test { public static void main(String[] args) { int [ ] [ ] values = {{3, 4, 5, 1}, {33, 6, 1, 2}}; int v = values[0][0]; for (int row = 0; row <values.length; row++) { for (int i = 1; i < values[1].length ; i++) if (v < values[row][i]){ System.out.print(v + " "); } } } }
28th Apr 2020, 5:26 AM
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~ - avatar
0
What is your program
28th Apr 2020, 4:14 AM
Vaibhav Narayan Patil
Vaibhav Narayan Patil - avatar