By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,834 Members | 1,680 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,834 IT Pros & Developers. It's quick & easy.

String converting to Stack/ Parsing

P: 1
Hello everyone my String reverse code works but my professor wants me to use pop top push or Stack code and parsing code could you please teach me how to make this code work with pop top push or Stack code and parsing code my professor i does not like me using buffer reader on my code and my professor did even give me an example code for parsing as well as pop push top or Stack code and i don't know how to do this code into parsing and pop push top code i been looking all through the bookstore and yet no avail i did see any book about parsing code as well as pop top push code please you teach me please
Expand|Select|Wrap|Line Numbers
  1. [import*;
  2.      import java.util.*;
  4.      class Reverse{
  6.            String reverse(String str) {
  7.                String rStr = new StringBuffer(str).reverse().toString();
  8.                return rStr;
  9.            }
  12.            String alphaOrder(String str){
  13.                char[] charArray = str.toCharArray();
  14.                Arrays.sort(charArray);
  15.                String aString = new String(charArray);
  16.                 return aString;
  17.            }
  19.            public static void main(String[] args) throws IOException {
  20.               System.out.print("Enter the String : ");
  21.              BufferedReader br =new BufferedReader(new InputStreamReader(;
  22.               String inputString = br.readLine();
  23.               System.out.println("String before reverse : " + inputString);
  24.               Reverse  obj = new Reverse();
  25.               String reverseString = obj.reverse(inputString);
  26.               String alphaString = obj.alphaOrder(inputString);
  27.               System.out.println("String after reverse : " + reverseString);
  28.            }
  29.       }
Jan 10 '10 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 9,731
Do you know what a Stack is?

If I were you I would start by researching what a Stack data structure is. For example a quick google search came up with this wiki article on what a Stack data structure is all about.

Once you understand what a Stack is...consider how you could use it to solve your problem. (Hint: you are going to need to "parse" or "break up" the text into chunks to accomplish your task).

After you understand what a Stack data structure is and have a good idea of how to use it to solve your problem.... I recommend that you go to the Java API and see if there is already a Stack class developed to save yourself time in creating one.

Jan 13 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.