Tuesday 26 December 2017

WAP to reverse each character as well as words of sentence

reverse each character as well as words of sentence,reverse each character as well as words of sentence in java,Write a program reverse each character as well as words of sentence,WAP to reverse each character as well as words of sentence,

Untitled Document package com.dashzin.prog;
import java.util.ArrayList;
import java.util.*;
import java.util.Scanner;
public class String10 {
public static void main(String[] args) {

int left, right=0;

Scanner sc=new Scanner(System.in);
System.out.println("enter the String");
String st=sc.nextLine();

String words[]=st.split(" ");

char ch[]=st.toCharArray();
List <Character> list=new ArrayList<>();

for(char c:ch){
list.add(c);
}
Collections.reverse(list);
Iterator it=list.iterator();
while(it.hasNext()){
System.out.print(it.next());
}
}
}

Output :

welcome to dashzin
nizhsad ot emoclew

DashZin

Author & Editor

Has laoreet percipitur ad. Vide interesset in mei, no his legimus verterem. Et nostrum imperdiet appellantur usu, mnesarchum referrentur id vim.

0 comments:

Post a Comment