Results 1 to 3 of 3
Thread: Could you please check my code?
- 08-11-2010, 10:52 AM #1
Member
- Join Date
- Jun 2010
- Posts
- 29
- Rep Power
- 0
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
- 08-11-2010, 11:03 AM #2
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
-
Similar Threads
-
can somebody check my code
By raven in forum New To JavaReplies: 2Last Post: 08-29-2010, 08:55 PM -
can anyone check my code?
By Harmesh Goyal in forum New To JavaReplies: 8Last Post: 06-29-2010, 05:43 AM -
Pls check why my code is giving a runtime error
By Beginner in forum New To JavaReplies: 3Last Post: 05-26-2010, 12:32 AM -
Plz Some one check my code
By TamTam in forum AWT / SwingReplies: 1Last Post: 02-07-2009, 11:24 PM -
Can someone check my code
By joz_12345 in forum Java 2DReplies: 7Last Post: 02-18-2008, 02:58 AM


LinkBack URL
About LinkBacks


Bookmarks