import java.io.*;
import java.util.Stack;
class test
{
public static void main(String[] args)throws IOException
{
Stack op;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
op = new Stack();
int t = Integer.parseInt(br.readLine());
while(t-->0)
{
try
{
char inp[] = br.readLine().toCharArray();
for(int i=0;i<inp.length;i++)
{
char c = inp[i];
if(c=='+' || c=='-' || c=='*' || c=='/' || c=='^')
{
op.push(c);
}
else if(c=='(')
{
op.push(c);
}
else if(c==')')
{
while(op.lastElement()!='(') //giving error in this line
{
System.out.print(op.pop());
}
if(op.capacity()>1)
{
op.pop();
}
else
{
op.clear();
}
}
else
{
System.out.print(c);
}
}
}
catch(IOException e)
{
e.printStackTrace();;
}
}
}
}
this code is running fine in my net beans but giving a compilation error
for the usage
while(op.lastElement()!='(')
or while(op.peek()!='(')
plz help...