Take FREE!! Online Mettl Mock Test to Crack TechM and Other Companies Written Exams.
Get Off-Campus Placement Jobs Info !!!
TCS NQT Technical and Managerial Round Interview Questions

Program Discussion :: Strings

Home > Programs > Strings

31 / 59

Write a program enter the sentence then print it in reverse order.


import java.io.*;
public class ReverseWord 
 public static void main(String[] args) 
  BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  System.out.println("Enter the string"); 
  String str=br.readLine();
  String a[]=str.split(" ");
  for(int i=a.length-1; i>=0; i--)
   System.out.print (a[i]+" ");

Asked In :: IBM

Post Your Answer Here:


Post Your Reply Here: