Reverse an Array | Java | Program to reverse the contents of an Array

  Рет қаралды 49,687

B Tech Computer Science

B Tech Computer Science

Күн бұрын

#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...

Пікірлер: 59
@pranavdeshpande3676
@pranavdeshpande3676 Жыл бұрын
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.
@pravarkunnath3519
@pravarkunnath3519 Жыл бұрын
Why does it work with odd array?
@pranavdeshpande3676
@pranavdeshpande3676 Жыл бұрын
@@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
@ankithareddy4497
@ankithareddy4497 Жыл бұрын
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
@BTechComputerScience
@BTechComputerScience Жыл бұрын
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. 😊
@MyraaKaul-o1v
@MyraaKaul-o1v Ай бұрын
I saw your comment, after I posted mine... yeah , I agree, for loop is way more simpler
@EarthWildEchoes
@EarthWildEchoes 2 жыл бұрын
Great explanation, Thank you!
@badineedinarendra9912
@badineedinarendra9912 2 ай бұрын
very nice explanation sir☺☺💎
@paul5007
@paul5007 Жыл бұрын
its always the indian guy Thank you
@BTechComputerScience
@BTechComputerScience Жыл бұрын
Hehe
@Gamuss12345
@Gamuss12345 Жыл бұрын
they are the Best!!
@rohitshinde7518
@rohitshinde7518 Жыл бұрын
Very helpful Thank you boss
@justinbabu8473
@justinbabu8473 4 ай бұрын
Superb🎉
@priyansh.u
@priyansh.u 3 ай бұрын
Thank you so much🙏
@hannanhub1717
@hannanhub1717 2 жыл бұрын
thanks bro..i could not understand swapping part
@BTechComputerScience
@BTechComputerScience 2 жыл бұрын
See my swapping video😊
@SuryaSurya-zl4ok
@SuryaSurya-zl4ok 5 ай бұрын
Then wht will be the given input is in odd number
@mohammadshahid5538
@mohammadshahid5538 7 ай бұрын
Make video on finding diagonal and indenity matrix
@MyraaKaul-o1v
@MyraaKaul-o1v Ай бұрын
int a[] = {1,2,3,4,5,6,7}; for(int i=a.length-1;i>=0;i--) { System.out.println(a[i]); } This will work as well!!!
@sagardarade
@sagardarade 8 ай бұрын
Perfect✅
@gayathridhana1000
@gayathridhana1000 Жыл бұрын
Thank you
@Sulakshit
@Sulakshit 11 ай бұрын
Bro what if it's not arranged in ascending or descending order ?
@BTechComputerScience
@BTechComputerScience 11 ай бұрын
It doesn't matter, it ll work😊
@AdityaSaini5654rdgfd
@AdityaSaini5654rdgfd 2 ай бұрын
what if number of inputs is odd
@sarankarthic5772
@sarankarthic5772 Жыл бұрын
This code doesn't work if there are duplicates in array
@happyteen7195
@happyteen7195 Жыл бұрын
it works
@aasimkhan271
@aasimkhan271 2 жыл бұрын
why using j=a.lenght-1 ??
@prathameshshaniware2377
@prathameshshaniware2377 2 жыл бұрын
Because the index of the array starts form 0, to access last index of the array you have to set array.lenght - 1.
@kartikpaul3161
@kartikpaul3161 2 жыл бұрын
Uspe tum 5 bhi likh sakte ho
@harishkumarreddy1999
@harishkumarreddy1999 10 ай бұрын
@@kartikpaul3161what if you don’t know the length of an array?
@naveenkumar6768
@naveenkumar6768 9 ай бұрын
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
@thakursclub6432
@thakursclub6432 3 ай бұрын
Because the length of the array is 6 but the last index is 5 . So we did length-1
@pablopronsky7364
@pablopronsky7364 Жыл бұрын
you are the beast
@GamerRohit713
@GamerRohit713 2 жыл бұрын
good work bro :) can you use better equipment for audio it is not audible and voice is not clear
@BTechComputerScience
@BTechComputerScience 2 жыл бұрын
Sure bro, thanks for letting me know
@HNTAutumnleaf
@HNTAutumnleaf 9 ай бұрын
Nice video! But can you do it in recursive?😁
@BTechComputerScience
@BTechComputerScience 9 ай бұрын
I should give it a try 🤔
@zuhaibabid12
@zuhaibabid12 Ай бұрын
Thnk uh sr but ...ur sop is wrong due to in error plzz expln sr
@yesitsme5948
@yesitsme5948 2 жыл бұрын
Error vasthundhi bro Last lo sop lo (array.to string (a));. ???
@BTechComputerScience
@BTechComputerScience 2 жыл бұрын
Arrays.toString(a)
@Notfound.5019
@Notfound.5019 2 жыл бұрын
you need to import import java.util.Arrays;
@sanskar2404
@sanskar2404 9 ай бұрын
​@@BTechComputerSciencewhy we use of it....we can write any other thing instead of it?
@ashutoshrai2717
@ashutoshrai2717 2 жыл бұрын
Why in last array.tostring ?
@mafia53042
@mafia53042 Жыл бұрын
it is a predefined method that shows arrays in a string format and similarly for 2d arrays we use arrays.deepToString method for output
@rubencherukuri91
@rubencherukuri91 Жыл бұрын
Please explain" reverse string"
@khushwindeshmukh6036
@khushwindeshmukh6036 Ай бұрын
Printing statement me Jo Likha vo samja nhi
@mohammadshahid5538
@mohammadshahid5538 7 ай бұрын
Make a video on binary search
@BTechComputerScience
@BTechComputerScience 7 ай бұрын
I have a binary search video on my channel 🙃
@mohammadshahid5538
@mohammadshahid5538 7 ай бұрын
@@BTechComputerScience ok I will check ✅
@unnatigupta1112
@unnatigupta1112 5 ай бұрын
👌👌👌👌👌👌
@asifmallik3742
@asifmallik3742 2 жыл бұрын
Error code .
@lofiboy7866
@lofiboy7866 2 ай бұрын
Time complexity is O(N) ? Na
@23mechnikilkannak59
@23mechnikilkannak59 2 жыл бұрын
Nice but we can't see your code
@gollarama2559
@gollarama2559 Жыл бұрын
Tell me reverse string bro
@vaishnavinannuru1018
@vaishnavinannuru1018 2 жыл бұрын
Bro getting errors
@BTechComputerScience
@BTechComputerScience 2 жыл бұрын
Can u share ur code?
@ashwinpoudel6909
@ashwinpoudel6909 2 жыл бұрын
@@BTechComputerScience i am also getting error
@yogeshchoudhary6839
@yogeshchoudhary6839 10 ай бұрын
100/100
@Jobupdates29
@Jobupdates29 10 ай бұрын
thank you
Count Pairs with given Sum | Java
6:11
B Tech Computer Science
Рет қаралды 6 М.
Вопрос Ребром - Джиган
43:52
Gazgolder
Рет қаралды 3,8 МЛН
Reversing the Values in an Array (Java Tutorial)
3:41
Bill Barnum
Рет қаралды 34 М.
Palindrome |  Program to check if a string is Palindrome | Java
9:31
B Tech Computer Science
Рет қаралды 120 М.
Program to Reverse A String in Java by Deepak
9:01
Smart Programming
Рет қаралды 421 М.
C Program To Print Elements of Array In Reverse Order
4:56
Technotip
Рет қаралды 90 М.
How to solve any Star Pattern Program
18:47
Simply Coding
Рет қаралды 1,2 МЛН
Finding Reverse of a Number | Java | Detailed Explanation
11:36
B Tech Computer Science
Рет қаралды 56 М.
Find maximum element in an array (Largest element)
5:42
Vivekanand Khyade - Algorithm Every Day
Рет қаралды 167 М.
Anagram | Check whether two strings are Anagram of each other | Java
10:46
B Tech Computer Science
Рет қаралды 40 М.