Can you write a java code without an extra array to reverse an array? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can you write a java code without an extra array to reverse an array?

Reverse array 'a' without the help of another array 'b'.

16th Oct 2017, 9:00 AM
Mohammed Abdul Azeem
Mohammed Abdul Azeem - avatar
3 Answers
+ 9
// It's too simple, actually. There's no need to burst out your mind :D int a[] = {9, 4, 6, 0, 7}; for(int i = a.length-1; i >= 0; i--) { System.out.print(a[i]+" "); }
16th Oct 2017, 9:06 AM
Dev
Dev - avatar
+ 5
Well you typed without the use array 'b' But I use ram array instead https://code.sololearn.com/cbtt8UJziO1J/?ref=app *Yawnnn* Why Java is not funnier than Assembly like this?
16th Oct 2017, 9:48 AM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
16th Oct 2017, 9:01 AM
Mohammed Abdul Azeem
Mohammed Abdul Azeem - avatar