469,934 Members | 2,497 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,934 developers. It's quick & easy.

String converting to Stack/ Parsing

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 java.io.*;
  2.      import java.util.*;
  3.  
  4.      class Reverse{
  5.  
  6.            String reverse(String str) {
  7.                String rStr = new StringBuffer(str).reverse().toString();
  8.                return rStr;
  9.            }
  10.  
  11.  
  12.            String alphaOrder(String str){
  13.                char[] charArray = str.toCharArray();
  14.                Arrays.sort(charArray);
  15.                String aString = new String(charArray);
  16.                 return aString;
  17.            }
  18.  
  19.            public static void main(String[] args) throws IOException {
  20.               System.out.print("Enter the String : ");
  21.              BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
  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
1 4057
Frinavale
9,735 Expert Mod 8TB
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.



-Frinny
Jan 13 '10 #2

Post your reply

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

Similar topics

15 posts views Thread by Freddie | last post: by
2 posts views Thread by Jonas Prismesen | last post: by
10 posts views Thread by Christopher Benson-Manica | last post: by
6 posts views Thread by Allan Bruce | last post: by
1 post views Thread by Sandra | last post: by
3 posts views Thread by Ryan Ternier | last post: by
1 post views Thread by amitbadgi | last post: by
2 posts views Thread by sam.barker0 | last post: by
6 posts views Thread by James Arnold | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.