Skip to content

Instantly share code, notes, and snippets.

@yusufsyaifudin
Created November 26, 2012 14:43
Show Gist options
  • Save yusufsyaifudin/4148564 to your computer and use it in GitHub Desktop.
Save yusufsyaifudin/4148564 to your computer and use it in GitHub Desktop.
Membalikkan karakter pada sebuah string
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package reversestring;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
*
* @author YusufSyaifudin
*/
public class Reversestring {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
try {
String str = input.readLine();
System.out.println("String asli : " + str);
//
str = new StringBuffer(str).reverse().toString();
System.out.println("String yang dibalik : " + str);
} catch (IOException ex) {
System.out.print(ex);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment