Reverse Print

// Reverse Print

import java.io.*;
public class recurse_rev_prn
{

public static void main()throws IOException
{
System.out.println(“Enter characters followed by enter key and to terminate use dot(.)”);
rev();
}

public static void rev() throws IOException
{
InputStreamReader x = new InputStreamReader(System.in);
BufferedReader y = new BufferedReader(x);

char c;
c=(char)y.read();

if(c!=’.’)
{
rev();

}
System.out.print(c);
}

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s