Advertisement
MkArs

Untitled

Nov 14th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. public static void main(String[] args) {
  2. String testString = "Text text test".toLowerCase();
  3. String codeString = "";
  4. String formattedString = "";
  5. for(char ch : testString.toCharArray()) {
  6. codeString += Character.isAlphabetic(ch) ? String.format("%-3s",ch - 'a' + 1) : ch;
  7. formattedString += Character.isAlphabetic(ch) ? String.format("%-3s",ch) : ch;
  8. }
  9. System.out.println(formattedString);
  10. System.out.println(codeString);
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement