Results 1 to 3 of 3
  1. #1
    Cylab is offline Member
    Join Date
    Jun 2010
    Posts
    29
    Rep Power
    0

    Default Could you please check my code?

    import java.util.*;
    class Test1{

    public static void main(String[] args) throws Exception{

    Stack<String> stack = new Stack<String>();
    String[] s ={"<","blue",">","<","red",">","H","<","/","rejd",">","<","/","blue",">"};
    boolean flag=true;

    for(int i=0;i<s.length;i++){

    if(s[i].equals("<")&&!s[i+1].equals("/")){
    System.out.println("pushed "+stack.push(s[i+1]));
    }else if(s[i].equals(">")&&!s[i+1].equals("<")){
    System.out.println(s[i+1]);
    }else if(s[i].equals("/")&&s[i+1].equals(stack.peek())){
    System.out.println("pop "+stack.pop());
    }else if(s[i].equals("/")&&!s[i+1].equals(stack.peek())){
    System.out.println(" error ");
    }else{flag=false;}
    [/INDENT]}
    System.out.println(stack);[/INDENT]}
    }

    It seems the codes contains some error, but I do not know how to fix it. please SOS

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    7

    Default

    Why did you start a new thread? One is enough. And use code tags when posting code.
    That is: [CODE]... your code goes here ... [/CODE]
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by PhHein View Post
    Why did you start a new thread? One is enough.
    Indeed. Locked.

    And use code tags when posting code.
    That is: [CODE]... your code goes here ... [/CODE]
    Indeed * Indeed

Similar Threads

  1. can somebody check my code
    By raven in forum New To Java
    Replies: 2
    Last Post: 08-29-2010, 09:55 PM
  2. can anyone check my code?
    By Harmesh Goyal in forum New To Java
    Replies: 8
    Last Post: 06-29-2010, 06:43 AM
  3. Pls check why my code is giving a runtime error
    By Beginner in forum New To Java
    Replies: 3
    Last Post: 05-26-2010, 01:32 AM
  4. Plz Some one check my code
    By TamTam in forum AWT / Swing
    Replies: 1
    Last Post: 02-08-2009, 12:24 AM
  5. Can someone check my code
    By joz_12345 in forum Java 2D
    Replies: 7
    Last Post: 02-18-2008, 03:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •