Java program to split a comma-separated string


Program

package com.candidjava;

public class ReverseCharacter
{
	String reverse = "";

	public String reverseString(String str)
	{

		if (str.length() == 1)
		{
			return str;
		}
		else
		{
			reverse += str.charAt(str.length() - 1) + reverseString(str.substring(0, str.length() - 1));
			return reverse;

		}
	}

	public static void main(String a[])
	{
		String input = "Candid Java Programming";
		System.out.println("Input String:"+input);
		ReverseCharacter srr = new ReverseCharacter();

		System.out.println("\nResult: " + srr.reverseString(input));

	}

}

Output

Input String: Welcome,to,Candid Java Program

Output String: 

Welcome

to

Candid Java Program



Related Post

Comments


©candidjava.com