Java Program to Reverse String without using in-built reverse() Method #java #interview #coding

preview_player
Показать описание
Java Program to Reverse a String without using the in-built reverse() Method
Learn how to reverse a string in Java manually, without using the reverse() method. This approach involves iterating through the string in reverse order and constructing a new string. This is a common interview question, perfect for honing your Java skills.

#java #interview #coding #javaprogramming #reverseString #codinginterview
Рекомендации по теме
Комментарии
Автор

Note: If you use StringBuilder then you can use it's reverse method to reverse the string.
It does not make sense to create StringBuilder object to just append small String. Even interviewer may ask you reverse a string without using any built-in reverse methods or additional classes like StringBuilder or StringBuffer.
Use StringBuilder for concatenating or appending long strings. This can be a most efficient way to reverse a string in Java without build-in method

JavaGuides
Автор

Little modification: we can use stringbuilder instead of concatenation.
Thanks for your videos!! 😊

thatguyadarsh
Автор

in a interview this wouldn't be satisfactory, since everytime we are making a new string when concating a new character, so for super large strings it is not advised to use this method, use a stringbuilder or a char[] (which can be later converted to string by toString() method)

prof.mangabhai
Автор

Is this a better way to use: `i >= input.length / 2` and each iteration swap first and last chars?

VasyaFF
Автор

Use StringBuilder with append instead of result = result + i-value

Maruthi
Автор

is the time complexity Big-O O(n)? if using reverse can reduce the time complexity

guohaofrankwu
Автор

You've chosen the most inefficient approach. Delete the video and think of what you have done.

phusicus_