Reverse an Array | Java | Program to reverse the contents of an Array
ฝัง
- เผยแพร่เมื่อ 14 ต.ค. 2024
- #Java #CoreJava #Collections #javaForBeginners Check out my Anime Store - anime-stoze.bl...
Subscribe to my channel so that you do not miss any topics.
The phone I used to record - amzn.to/34V1uqX
Phone stand used - amzn.to/3igP9QZ
Lighting I used - amzn.to/3IpYyQO
My laptop - amzn.to/3L1gt1Z
My gaming Keyboard - amzn.to/3Jt66mY
My gaming Mouse - amzn.to/36B4eKE
Headphones - amzn.to/3u3RnbC
Find the code for the above program here - musclecode.blo...
My other videos-
Finding Reverse of a Number - • Finding Reverse of a N...
Check if the given number is Prime Number - • Check if given number ...
Finding Minimum and Maximum value from an Array - • Finding Minimum and Ma...
Area and Perimeter of Rectangle - • Area and Perimeter of ...
Program to check if a string is Palindrome - • Palindrome | Program ...
Find the sum of digits of a number - • Find sum of digits of ...
Count the number of Digits of a Number - • Count the number of Di...
Java program to print Fibonacci Series - • Java program to print ...
Find Factorial of a number - • Find Factorial of a nu...
Check if a given year is Leap Year - • Check if a given year...
C++ program to Swap two numbers (Using extra variable) - • C++ program to Swap tw...
C++ program to find if a number is ODD or EVEN - • C++ program to find if...
C++ program to find Quotient and Remainder - • C++ program to find Qu...
C++ program to find Sum, Difference, Product, and Divison of two numbers - • C++ program to find Su...
for(int i=a.length-1;i>=0;i--) {
System.out.println(a[i]);
} you can give like this also simple method to reverse array
Hey there, this is also a good solution, but here all u can do is print in reverse order. Many interviewers won't accept this... they ll ask for an array which has reversed elements of the original array, which can be used for any other operation if needed. For example if the question says - reverse the array and find the index of the largest/smallest number in it.
Hence leaning to create a reversed array is also important. 😊
Worked!! I wondered after watching the video that how will it work for odd number of elements in array, but later realized that it does and why it does. Thanks for the video.
Why does it work with odd array?
@@pravarkunnath3519 In odd array there will be left a middle element right!
We don't have to touch it, it will stay at its position only even after reversing.
Hence It works
Hope it helps
Enjoy coding
Thank you so much🙏
Great explanation, Thank you!
Make video on finding diagonal and indenity matrix
its always the indian guy
Thank you
Hehe
they are the Best!!
Then wht will be the given input is in odd number
Very helpful Thank you boss
thanks bro..i could not understand swapping part
See my swapping video😊
Superb🎉
Bro what if it's not arranged in ascending or descending order ?
It doesn't matter, it ll work😊
Please explain" reverse string"
This code doesn't work if there are duplicates in array
it works
Nice video! But can you do it in recursive?😁
I should give it a try 🤔
thank you
why using j=a.lenght-1 ??
Because the index of the array starts form 0, to access last index of the array you have to set array.lenght - 1.
Uspe tum 5 bhi likh sakte ho
@@kartikpaul3161what if you don’t know the length of an array?
a.length - it is used to find the length of one particular array, here the array name is a, so we put a.length and the reason for a.length-1 is simple we just need the index to its common to do -1 with the length of that particular array, hope it's useful
Because the length of the array is 6 but the last index is 5 . So we did length-1
Make a video on binary search
I have a binary search video on my channel 🙃
@@BTechComputerScience ok I will check ✅
good work bro :)
can you use better equipment for audio it is not audible and voice is not clear
Sure bro, thanks for letting me know
👌👌👌👌👌👌
Perfect✅
Why in last array.tostring ?
it is a predefined method that shows arrays in a string format
and similarly for 2d arrays we use arrays.deepToString method for output
Error vasthundhi bro
Last lo sop lo (array.to string (a));. ???
Arrays.toString(a)
you need to import import java.util.Arrays;
@@BTechComputerSciencewhy we use of it....we can write any other thing instead of it?
Nice but we can't see your code
you are the beast
Tell me reverse string bro
Error code .
100/100
Bro getting errors
Can u share ur code?
@@BTechComputerScience i am also getting error
Thank you