Skip to content

Instantly share code, notes, and snippets.

@DimasInchidi
Last active March 29, 2017 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DimasInchidi/3cccf109d9978f4efe7d331ccc3df222 to your computer and use it in GitHub Desktop.
Save DimasInchidi/3cccf109d9978f4efe7d331ccc3df222 to your computer and use it in GitHub Desktop.
class Replace {
public static void main (String[] args) throws java.lang.Exception {
Map<String, String> map = new HashMap<String, String>();
//n?kfv-=xa.
map.put("a", "n");
map.put("b", "?");
map.put("c", "k");
map.put("d", "f");
map.put("e", "v");
map.put("f", "-");
map.put("g", "=");
map.put("h", "x");
map.put("i", "a");
map.put("j", ".");
java.util.Scanner reader = new java.util.Scanner(System.in);
System.out.print("Masukan pesan: ");
String pesan = reader.nextLine().replaceAll("[^abcdefghij]", "*");
for (Map.Entry<String, String> entry : map.entrySet()) {
pesan = pesan.replace(entry.getKey(), entry.getValue());
}
System.out.print(pesan);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment