Video Title: Java Program to Reverse an Array
Hello friends in this tutorial we will write a program to reverse an area so what does it mean by reverse and array so let’s let’s take an array or let’s take an array let’s put some values 7 8 9 what is the reverse of this site is so
The reverse is 9 8 7 1 so let’s think for a moment how to reverse an array so see what if you think logically then what we have done is we have swept the position of an array element so the first position is set with last and
Second position with second last and so on so in this way we have reversed an array so let’s write a simple Java program to reverse an input array so let’s start writing let’s let’s take a size of an array from user let’s declare an array let’s take an
Input value from an array so our array size will be less than so we have initialize I to 0 and our loop will break when I is equal to n so and so when the value of I is less than and we have take K and input values so we have
But array values now we have an array and now we have to write the logic to reverse an array reverse and print this array values so let’s declare some variables let’s declare a time let’s declare two indexes start which will initially assign a value of 0 and end
Which will initially assign a value of n minus 1 so start will point to point to the start of an array and n will point to the last element of an array let’s reverse it so check if a start is less than and so start Valley is less than n then set the
Values a start and an end to be 10 now we will increment the value of star and decrement the value of n don’t worry if you did not understand what I have done let let me explain this so suppose our array contains value 1 2 3 4 and 5 so
Initially so we have a array with with a length of 5 so start will points to 0 and the end will point 5 minus 1 and X 4 0 1 2 3 4 so we have checked whether if I start is less than and it means 0 is
Less than 4 then our condition is true in Tampere we have assigned a area of start which is 1 and now in array of arrays start index we have assigned array and so we have assigned 5 in 1 and N in array n we have assigned temp so we
Have swept this value first with 5 now we have incremental start index now it points to this index next index of an array and decremented and now it’s point to this one again our condition true and we have served this value 2 and 4 now
Start is incremented n points to 3 and n is decremented n points to this index now start is not less than and now condition fails and print this array system dot out dot println array after reversing printing an array after reverse so for inch J
Equal to 0 J is less than n J this place system contagion now we print then X of G so now our program is completed let’s execute and run this program until the size of an array let’s take 6 enter some value 6 to 9 1 9
19 for to let’s see the reverse of this area 2 for 19 9 to 6 so oh this is a very simple program and I hope you have understand it thanks for watching this video for more such videos subscribe our youtube channel thank you
-
Sale!
Wireless WIFI Repeater Extender Amplifier Booster 300Mbps
$29.99$14.99 Add to cartWireless WIFI Repeater Extender Amplifier Booster 300Mbps
Categories: Electronics, Wi-Fi Router, Wireless Wi-Fi Extender Tags: 300Mbps, 802.11N, Amplifier, Booster, Extender, mobile wi-fi booster, Remote, WIFI, Wireless, Wireless WIFI, Wireless WIFI Repeater, Wireless WIFI Repeater Extender, Wireless WIFI Repeater Extender Amplifier, Wireless WIFI Repeater Extender Amplifier Booster, Wireless WIFI Repeater Extender Amplifier Booster 300Mbps$29.99$14.99 -
Sale!
Full RGB Light Design Gaming Headset Headphones with Mic
$24.99$14.99 Add to cartFull RGB Light Design Gaming Headset Headphones with Mic
Categories: Electronics, Gaming, Gaming Headsets Tags: Design, Full, Full RGB Light Design Gaming Headset, Full RGB Light Design Gaming Headset Headphones, Full RGB Light Design Gaming Headset Headphones with Mic, Gamer, Gaming, Gaming Headset Headphones, gaming headset wireless, Headphone, Headphones, Headset, Light, Mic, Package, RGB$24.99$14.99 -
Sale!
Wireless BlueTooth Multi-Device Keyboard Mouse Combo
$39.99$19.99 Add to cartWireless BlueTooth Multi-Device Keyboard Mouse Combo
Categories: Electronics, Gaming, Gaming Keyboards, Keyboard Mouse Combos Tags: Combo, Keyboard, keyboard mouse combos, Mouse, MultiDevice, Set, WireKeyboard Mouse Combo, Wireless, Wireless BlueTooth Keyboard Mouse Combo, Wireless BlueTooth Keyboard Mouse Combos, Wireless BlueTooth Multi-Device Keyboard Mouse Combo, Wireless BlueTooth Multi-Device Keyboard Mouse Combos$39.99$19.99 -
Sale!
High Back Leather Executive Adjustable Swivel Gaming Chair with Headrest and Lumbar
$199.99$139.99 Add to cartHigh Back Leather Executive Adjustable Swivel Gaming Chair with Headrest and Lumbar
Categories: Gaming, Gaming Chairs Tags: Adjustable, Chair, computer chairs, Desk, Executive, Gaming, Girl, Headrest, High, High Back Leather Executive Adjustable Swivel Gaming Chair, High Back Leather Executive Adjustable Swivel Gaming Chair with Headrest, High Back Leather Executive Adjustable Swivel Gaming Chair with Headrest and Lumbar, High Back Leather Executive Adjustable Swivel Gaming Chairs, Leather, Lumbar, Office, Racing, Swivel$199.99$139.99 -
Sale!
Professional LED Light Wired Gaming Headphones with Noise Cancelling Microphone
$29.99$19.99 Select optionsProfessional LED Light Wired Gaming Headphones with Noise Cancelling Microphone
SKU: N/A Categories: Electronics, Gaming, Gaming Headsets Tags: Cancelling, Gaming, Gaming Headphones with Noise Cancelling Microphone, gaming headset, Headphones, Headset, LED, Light, Mic, Microphone, Noise, Professional, Professional LED Light Wired Gaming Headphones, Professional LED Light Wired Gaming Headphones with Noise Cancelling Microphone, Wired, Wired Gaming Headphones, Wired Gaming Headphones with Noise Cancelling Microphone$29.99$19.99 -
Sale!
Gaming Desk with LED Lights USB Power Outlets and Charging Ports
$349.99$249.99 Select optionsGaming Desk with LED Lights USB Power Outlets and Charging Ports
SKU: N/A Categories: Computer Desk, Gaming, Gaming Desk Tags: and Charging Ports, Charging, Desk, Desks, Gaming, gaming desk with led lights, Gaming Desks with LED Lights, Home, LED, Lights, Monitor, Office, Outlets, Port, Power, Room, Stand, USB, USB Power Outlets, White, Workstation$349.99$249.99 -
Sale!
Wired Mixed Backlit Anti-Ghosting Gaming Keyboard
$99.99$79.99 Add to cartWired Mixed Backlit Anti-Ghosting Gaming Keyboard
Categories: Electronics, Gaming, Gaming Keyboards Tags: Antighosting, Backlit, Blue, brown, Gaming, Gaming Keyboard, gaming keyboards, gaming keyboards and mouse, Keyboard, Laptop, Switch, Wired, Wired Mixed Backlit Anti-Ghosting Gaming Keyboard, Wired Mixed Backlit Anti-Ghosting Gaming Keyboards, Wired Mixed Backlit Gaming Keyboard$99.99$79.99 -
Sale!
Wireless Bluetooth 5.3 ANC Noise Cancellation Hi-Res Over the Ear Headphones Headset
$119.99$59.99 Add to cartWireless Bluetooth 5.3 ANC Noise Cancellation Hi-Res Over the Ear Headphones Headset
Categories: Electronics, Gaming, Gaming Headsets Tags: 5.3 ANC Noise Cancellation Hi-Res Over the Ear Headphones Headset, ANC, Audio, Bluetooth, Cancellation, Ear, Earphone, gaming headset, Headphones, Headset, Hi-Res Over the Ear Headphones Headset, HiRes, Noise, Wireless, Wireless Bluetooth 5.3 ANC Noise Cancellation Hi-Res Headphones, Wireless Bluetooth 5.3 ANC Noise Cancellation Hi-Res Over the Ear Headphones Headset, Wireless Bluetooth 5.3 ANC Noise Cancellation Hi-Res Over the Ear Headphones Headsets$119.99$59.99 -
Sale!
Wired Sports Gaming Headset Earbuds with Microphone
$19.99$9.99 Select optionsWired Sports Gaming Headset Earbuds with Microphone
SKU: N/A Categories: Gaming, Gaming Headsets Tags: Accessories, Earbud, Earphone, Earphones, Gaming, gaming headset with microphone, Headphones, Headset, IOS, Microphone, Sports, Wired, Wired Sports Gaming Headset Earbuds, Wired Sports Gaming Headset Earbuds with Microphone, Wired Sports Headset Earbuds$19.99$9.99 -
Sale!
150W Universal Multi USB Fast Charger 16 Port MAX Charging Station
$49.99$29.99 Add to cart150W Universal Multi USB Fast Charger 16 Port MAX Charging Station
Categories: Charging Stations, Electronics Tags: 150W, 150W Charging Station, 150W Universal Multi USB Charging Station, 150W Universal Multi USB Fast Charger 16 Port MAX Charging Station, 150W Universal Multi USB Fast Charger 16 Port MAX Charging Stations, 150W Universal Multi USB MAX Charging Station, 16 Port MAX Charging Station, 3.5A, Charger, Charging, Fast, laptop charging stations, Max, Multi, Port, Stand, Station, Universal, USB$49.99$29.99
Reverse an Array Explained in Hindi – https://www.youtube.com/watch?v=0-NDm485RcI
I think there is a simpler way
So for(int i=lenght-1; i>=0; i++)
System.out print(array[i] + " );
I am reversing array like this so please let me know which array reversing algo is best this single length- 1 or yours.
I have started learning DSA so please let me know
send code plz I am confuse 😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢
thnx bro
Sir, is this the most efficient way to reverse an array?
can you give can example of this a "A method reverse() that reverses a string if its length (consider only alphanumeric characters, e.g., letters and numbers) is a multiple of 2, otherwise it will return the input string."
Basic se bta de yarr ye toh intermediate level kaa bta rha hai
Everytime hear an Indian accent dude teaching tutorial, I know he will be goddamn good.
this video is so helpful seriously. thank you. have been looking for the correct logic everywhere but couldn't find it. thanks
This is so brilliant 👏
how about if the last index was 0 ?
why can't we use decrement loop for reversing an array???
Woah woah
I am unable to see the code the written part is coming infront of the screen
nice keep it up
thank u!!!
I don't think it was necessary to use for loop on line 49 to print the reversed array, u could have used Arrays.toString(arr) to directly print that array.
i was working on this for hours and i could reverse them by using simple reverse "for (x=length-1;x>=0;x–)" and then print but i needed to use "temp" as the question required, FINALLY i got it, thank u sir
Greate Job
Nice explanation ❤
String reverse without affecting special characters aricent
Thanks, nice simple to understand explanation.
thank you so much for this!
This but with strings..
Finally someone that actually explains how to programm and what everything means and does!
Good explanation!
nice technique
Praise be the java writing man.
thanks man nice video!
Y not u direct come to logic rather than writing class PSVM with scanner then print the array after that we forget why we are watching the videos or our aim to watch for reverse array..
this is a good video i need to get more sleep so i can understand what I'm actually learning I understand the n-1 i.e front has to break the back in order for the loop to break