Skip to content

Instantly share code, notes, and snippets.

@chetanppatil
Created January 29, 2019 11:00
Show Gist options
  • Save chetanppatil/d72bacf5711ef4b353fcd038e80374cc to your computer and use it in GitHub Desktop.
Save chetanppatil/d72bacf5711ef4b353fcd038e80374cc to your computer and use it in GitHub Desktop.
java program to reverse string and replace space with dot
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner read = new Scanner(System.in);
String s = read.nextLine();
String[] split = s.split(" ");
String result = "";
for (int i = split.length - 1; i >= 0; i--) {
//result += (split[i] + ".");
result += split[i];
if(i != 0){
result += ".";
}
}
System.out.println(result.trim());
//System.out.println(str);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment