Java Tutorials
Spring Tutorial: What is Spring Framework & How to Install
What is Spring Framework? Spring Framework is an open-source framework for building web...
In this example program, we will reverse a string entered by a user.
We will create a function to reverse a string. Later we will call it recursively until all characters are reversed.
package com.gtupapers;
public class ReverseString {
public static void main(String[] args) {
String myStr = "gtupapers";
//create Method and pass and input parameter string
String reversed = reverseString(myStr);
System.out.println("The reversed string is: " + reversed);
}
//Method take string parameter and check string is empty or not
public static String reverseString(String myStr)
{
if (myStr.isEmpty()){
System.out.println("String in now Empty");
return myStr;
}
//Calling Function Recursively
System.out.println("String to be passed in Recursive Function: "+myStr.substring(1));
return reverseString(myStr.substring(1)) + myStr.charAt(0);
}
}
String to be passed in Recursive Function: uru99 String to be passed in Recursive Function: ru99 String to be passed in Recursive Function: u99 String to be passed in Recursive Function: 99 String to be passed in Recursive Function: 9 String to be passed in Recursive Function: String in now Empty The reversed string is: 99uruG
What is Spring Framework? Spring Framework is an open-source framework for building web...
Java is a programming language and a computing platform for application development. It was first...
Java has had several advanced usage application including working with complex calculations in...
Following is a step by step guide to install Java on Linux. In this training, we will install Java on...
Follow the simple steps below to compile and execute any JAVA program online using your favourite...
What is a Build Tool? A build tool is a programming tool which is used to build a new version of a...