0
Why I'm getting garbage value..??? what's wrong with this code😓..... Answer should be..... index = [ 0, 3]
11 Réponses
+ 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
+ 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.
+ 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
+ 1
Davinder Kumar
That's your logic problem. I just given answer on your Garbage value question.
You have to check your logic again.
+ 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.
+ 1
no you didn't get my point anyway thanks for giving your precious time....!
+ 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.
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 😓
0
no that's wrong answer
0
answer should be index = [ 0 , 3 ]
0
My Logic is completely right i believe... there might be something due to which it throws such value