Bài đăng

Hiển thị các bài đăng có nhãn Reverse

Cách đảo ngược một chuỗi String trong Java (How to Reverse A String In Java)

In This Tutorial We Will Discuss  How To Reverse A String In Java . Although There Are Many Ways To Get The Solution But We Are Sharing 5 Different Ways To  Reverse A String. This Question Is Frequently Asked In The Technical Interview Of Java.This Question Is Easy , But Please Mark This Question In Your To Do List Before Attending Any Technical Interview In Java. First We Will Understand The Question By Writing Example. Input :   Alive is awesome Output : emosewa si evilA Input : Be in present Output : tneserp ni eB Points to Keep in Mind Before attempting the Solution: 1. String class in java do not have reverse() method , StringBuilder class does have built in reverse() method. 2. StringBuilder class do not have toCharArray() method , while String class does have toCharArray() method. Pseudo Code for Reverse String Method 1: 1. The user will input the string to be reversed. 2. First we will convert String to character array by using the built in java String class met