Reverse Characters in String
This program reverses characters of a string.
Problem Statement
Write a Java program to reverse characters in a string.
Source Code
| 1 | public class ReverseCharacters { |
| 2 | public static void main(String[] args) { |
| 3 | System.out.println("Eduinq Reverse Characters"); |
| 4 | String str="Eduinq"; |
| 5 | String rev=new StringBuilder(str).reverse().toString(); |
| 6 | System.out.println("Reversed string: "+rev); |
| 7 | } |
| 8 | } |
Program Output
Eduinq Reverse Characters Reversed string: qniudE
Explanation
StringBuilder provides a built-in reverse() method that converts the string into its reversed form, demonstrating character-level reversal.