Тёмный

Java Program to Reverse String without using in-built reverse() Method  

Java Guides
Подписаться 158 тыс.
Просмотров 17 тыс.
50% 1

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

Опубликовано:

 

2 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 15   
@JavaGuides
@JavaGuides 7 месяцев назад
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
@prof.mangabhai
@prof.mangabhai 7 месяцев назад
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)
@thatguyadarsh
@thatguyadarsh 7 месяцев назад
Little modification: we can use stringbuilder instead of concatenation. Thanks for your videos!! 😊
@VasyaFF
@VasyaFF 7 месяцев назад
Is this a better way to use: `i >= input.length / 2` and each iteration swap first and last chars?
@Maruthi468
@Maruthi468 6 месяцев назад
Use StringBuilder with append instead of result = result + i-value
@luncsffrfun-ch1zf
@luncsffrfun-ch1zf 24 дня назад
How to use the Exception hamdling??
@phusicus_404
@phusicus_404 7 месяцев назад
You've chosen the most inefficient approach. Delete the video and think of what you have done.
@JavaGuides
@JavaGuides 7 месяцев назад
You show me efficient approach
@nabinghoshmaths6834
@nabinghoshmaths6834 7 месяцев назад
​@@JavaGuides May be we can use Stringbuffer to append the character. But this way is also fine.
@JavaGuides
@JavaGuides 7 месяцев назад
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 don't use any other classes and in-built methods other than String.
@phusicus_404
@phusicus_404 7 месяцев назад
@@JavaGuidesSwap characters from both halves of the string from the ends to the middle. It was among the comments.
@aribasiebel
@aribasiebel 7 месяцев назад
Solve it recursively. It's most efficient 😂
@guohaofrankwu7317
@guohaofrankwu7317 7 месяцев назад
is the time complexity Big-O O(n)? if using reverse can reduce the time complexity
@Yaduvanshi-nw3yr
@Yaduvanshi-nw3yr 6 месяцев назад
Another way using recursion method
@Kamrankhan23333
@Kamrankhan23333 7 месяцев назад
Can you make one using stack ds?
Далее
UUID vs INT: What’s Better For Your Primary Key?
9:40
🎙Пою РЕТРО Песни💃
3:05:57
Просмотров 1,3 млн
Learn Java in 14 Minutes (seriously)
14:00
Просмотров 4,8 млн
Reverse Each Word In Given String | Java | Ashok IT
12:24
Premature Optimization
12:39
Просмотров 813 тыс.