fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main(String[] args) {
  11. //takes a string and prints all the letters backwards all on one line
  12.  
  13. String fruit = "apple";
  14. backwards(fruit);
  15. }
  16.  
  17. public static void backwards(String theFruit) {
  18. int length = theFruit.length() - 1;
  19. int counter = 0;
  20. while(length >= counter) {
  21. char theCharacter = theFruit.charAt(length);
  22. System.out.println(theCharacter);
  23. length--;
  24. }
  25. }
  26. }
Success #stdin #stdout 0.1s 320256KB
stdin
Standard input is empty
stdout
e
l
p
p
a