Tagged: ,

  • Reverse the string..

     Indu updated 2 months, 2 weeks ago 2 Members · 2 Posts
  • Akash 

    Administrator
    at

    Write a program to reverse the string.

  • Indu

    Member
    at

    import java.util.Scanner;

    public class ReverseString{

    public static void main(String []args){

    Scanner Scan=new Scanner(System.in);

    System.out.println(“Enter the string which is to be reversed “);

    String str=Scan.nextLine();

    String rev=””;

    for(int i=str.length()-1;i>=0;i–){

    rev=rev+str.charAt(i);

    }

    System.out.println(“The reversed string is “+rev);

    }

    }

Log in to reply.

Original Post
0 of 0 posts June 2018
Now
KodNest Training New Batch is starting on 02nd November 2020. Attend one week free demo classes.Register Now

New Report

Close