Does anyone know how to trace arrays in java?? Please help me trace this program ! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Does anyone know how to trace arrays in java?? Please help me trace this program !

int [] array = {1,2,3,4,5}; int[] arr2 = new int[2]; doOne(array,arr2); }// end of main // public static void doOne(int[] arr, int[]z){ for (int i=0; i<arr.length; i++) arr[i] = arr[i]*2; z[0] = arr[1]+z[1]+3; } (Tracing means to write down the execution of the code step by step, showing how the variable changes)

20th May 2020, 8:51 PM
Zainab Z
1 Answer
0
Trace means? What way..? Explain it mmwith what you trying... In code snippet, z[0] you can write outside of loop, because no value changing, since using constant indexes and z[1] is assigned to default 0 value yet.. Do you want to print array results.?
20th May 2020, 9:25 PM
Jayakrishna 🇮🇳