Why I'm getting garbage value..??? what's wrong with this code😓..... Answer should be..... index = [ 0, 3] | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why I'm getting garbage value..??? what's wrong with this code😓..... Answer should be..... index = [ 0, 3]

https://code.sololearn.com/cIS8dwVxquqU/?ref=app

10th Apr 2022, 9:47 AM
Davinder Kumar
Davinder Kumar - avatar
11 Answers
+ 4
Davinder Kumar You are printing array 'result' which is giving address of 'result' array not garbage value. print this: System.out.println(result[0]); System.out.println(result[1]); or you can print like this: System.out.println(Arrays.toString(result)); note : import - Arrays class
10th Apr 2022, 10:38 AM
A͢J
A͢J - avatar
+ 2
Davinder Kumar You have assigned array not value and when you print array or object it's print address (which is not a garbage value) not value. If you want value then print like that as I replied previously.
10th Apr 2022, 11:26 AM
A͢J
A͢J - avatar
+ 2
Davinder Kumar One more thing 7 exist at position 1 and 2 then how your output should be [0, 3]? Here is solution of your "Garbage value" as you said: https://code.sololearn.com/c88IY4U25LIu/?ref=app
10th Apr 2022, 12:10 PM
A͢J
A͢J - avatar
+ 1
Davinder Kumar That's your logic problem. I just given answer on your Garbage value question. You have to check your logic again.
10th Apr 2022, 11:38 AM
A͢J
A͢J - avatar
+ 1
Davinder Kumar Again I am telling that's not the problem of that value. If you want to see actual result then print this: Arrays.toString(result) Instead of result Remember you have to import Arrays class before printing Arrays.toString(result) import java.util.Arrays; --------- Note: just search on Google why result comes like that when you print array object.
10th Apr 2022, 12:05 PM
A͢J
A͢J - avatar
+ 1
no you didn't get my point anyway thanks for giving your precious time....!
10th Apr 2022, 2:56 PM
Davinder Kumar
Davinder Kumar - avatar
+ 1
Davinder Kumar I got your point but I think you didn't get what I said even I also explained what is right and what is wrong.
10th Apr 2022, 3:50 PM
A͢J
A͢J - avatar
0
look i have assigned function's value in result just to print the final result. still don't get why I'm getting such output 😓
10th Apr 2022, 10:51 AM
Davinder Kumar
Davinder Kumar - avatar
0
no that's wrong answer
10th Apr 2022, 11:29 AM
Davinder Kumar
Davinder Kumar - avatar
0
answer should be index = [ 0 , 3 ]
10th Apr 2022, 11:30 AM
Davinder Kumar
Davinder Kumar - avatar
0
My Logic is completely right i believe... there might be something due to which it throws such value
10th Apr 2022, 11:44 AM
Davinder Kumar
Davinder Kumar - avatar