In this Problem we learn how to Reverse a String in Java. User will Enter a string and that string pass to the parameter of another string which has function to reverse the user string. At the end of the program the program will display string before reversing and after reversing.
Source Code
package com.ancodingpoint.ww.w; import java.util.Scanner; public class String_Function { public static void main(String[] args) { Scanner input = new Scanner (System.in); String sentence = ""; System.out.println(" Enter your Story Here .... ! "); sentence = input.nextLine(); String reverse = new StringBuffer(sentence).reverse().toString(); System.out.println(" \n Your Story Before Reverse \n " + sentence); System.out.println(" \n Your Story After Reversing the String \n " + reverse); } }
0 comments:
Post a Comment