Tuesday 26 December 2017

WAP to reverse the charecter in the word of give sentence

reverse the charecter in the word of give sentence,WAP to reverse the charecter in the word of give sentence, reverse the charecter in the word of give sentence in java, WAP to reverse the charecter in the word of give sentence in java

reverse the charecter in the word of give sentence

package com.dashzin.prog;
import java.util.Scanner;
public class String11 {

public static void main(String[] args) {

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

String[] words = st.split(" ");
String reversedString = "";
for (int i = 0; i < words.length; i++)
{
String word = words[i];
String reverseWord = "";
for (int j = word.length()-1; j >= 0; j--)
{
/* The charAt() function returns the character
* at the given position in a string
*/
reverseWord = reverseWord + word.charAt(j);
}
reversedString = reversedString + reverseWord + " ";
}
System.out.println(st);
System.out.println(reversedString);
}
}

Output :

welcome to dashzin
emoclew ot nizhsad

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