pro-Prog

Quick-Tips :

1. Converting an Array to List  : new ArrayList<Element>(Arrays.asList(array))

2. Reverse History of References in Eclipse : <CTRL or APPL> + [

3. List of Short Keys in Eclipse : <CTRL or APPL> + SHIFT + L

Reverse String

1. Plain Reverse String using Java String

public class Reverse {
    public static void main(String[] args) {

        String input;    // Used for the input string.
        String reversed; // Reversed form or the input string.

        while (true) {
            input = JOptionPane.showInputDialog(null, "Enter a string");
            if (input == null) break;

            reversed = "";
            for (int i=0; i<input.length(); i++) {
                reversed = input.substring(i, i+1) + reversed;
            }

            JOptionPane.showMessageDialog(null, "Reversed:\n" + reversed);
        }
    }
}

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