Coding Challenge Day-2: Problem 3: Reverse a String

Hello! So I’m doing a 30 day coding challenge where I solve around 3-5 questions per day and thought of posting them here on my blog so that you guys can join the challenge too!

Welcome to Coding challenge Day 2: Problem three! Be sure to post your answers, queries etc in the comments!!

Problem: Reverse a String

Sample input: Hello
Output: Reversed String: olleH

Sample input: pink123
Output: 321knip

Sample input: Yellow Flower
Output: Reversed String: rewolF wolleY


  • Run loop starting from end of loop to index poisition 0
  • store each character in another string
package extra;

public class Program001reverse_string {
	public static void main (String [] args){
		String str= "Yellow Flower";
		String reverse="";
		int length= str.length();
		for(int i=length-1; i>=0; i--){
			reverse+= str.charAt(i);
		System.out.println("Reversed String: " + reverse);


Happy Learning!!

Leave a Reply


Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this:
search previous next tag category expand menu location phone mail time cart zoom edit close