Created
May 24, 2017 16:49
-
-
Save peter279k/53e311c78ccbd697c0545cdccd224eb8 to your computer and use it in GitHub Desktop.
TQC+ JAVA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class JPA03 { | |
static Scanner keyboard = new Scanner(System.in); | |
public static void main(String[] args) { | |
System.out.print("Input a string: "); | |
String str = keyboard.nextLine(); | |
System.out.println(strReverse(str)); | |
System.out.print("Input a string: "); | |
str = keyboard.nextLine(); | |
System.out.println(strReverse(str)); | |
} | |
public static String strReverse(String str) { | |
if(str.equals("")) { | |
return ""; | |
} | |
return str.substring(str.length()-1) + strReverse(str.substring(0, str.length()-1)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment