NullPointerException

Hello! I am writing a java app to convert Infix to Postfix, and I am getting a NullPointerException that I cannot trace. Any suggestions?

toPostfixTester.java

publicclass toPostfixTester{

publicstaticvoid main (String[] args){

toPostfix convertor =new toPostfix("1+2+3");

convertor.convert();

System.out.println(convertor.returnOutput());

}

}

toPostfix.java

publicclass toPostfix{

String input;

lifoStack output;

lifoStack stack;

public toPostfix (String i){

input = i;

stack =new lifoStack();

}

// Driver for conversion from infix to postfix

publicvoid convert(){

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

char current = input.charAt(i);

switch (current){

case'+':

case'-':

processOperator(current, 1);

break;

case'*':

case'/':

processOperator(current, 2);

break;

case'(':

stack.push(current);

break;

case')':

processParen(current);

break;

default:

output.push(current);

break;

}

}

while (!stack.isEmpty())

output.push(stack.pop());

}

// Method to handle precedence and operate on Operators

publicvoid processOperator(char operate,int precA){

int precB;

while (!stack.isEmpty()){

if (stack.view().equals('('))// If operator is a (

break;// leave well enough alone.

else{

if (stack.view().equals('+') || stack.view().equals('-'))

precB = 1;

else

precB = 2;

}

if (precA < precB){// If the precedence of our

break;// top operator is less than the new

}// leave well enough alone.

else{

output.push(stack.pop());

}

}

stack.push(operate);

}

// Extra method to handle Parenthesis

publicvoid processParen(char incoming){

while (!stack.isEmpty()){

if (stack.view().equals('(')){

stack.pop();

break;

}

else{

output.push(stack.pop());

}

}

}

public String returnOutput(){

return output.returnOutput();

}

}

lifoStack.java

import java.util.LinkedList;

publicclass lifoStack{

static LinkedList lifoStack =new LinkedList();

public Object pop(){

Object temp = lifoStack.getLast();

lifoStack.removeLast();

return temp;

}

publicvoid push(Object o){

lifoStack.add(o);

}

public Object view(){

return lifoStack.getLast();

}

publicboolean isEmpty(){

return lifoStack.isEmpty();

}

public String returnOutput(){

return lifoStack.toString();

}

}

[6786 byte] By [Cody.DeHaana] at [2007-11-26 20:02:34]
# 1
are you studying at the u of a? cause I am also assigned this project
aditya15417a at 2007-7-9 23:01:53 > top of Java-index,Java Essentials,Java Programming...
# 2
lifoStack output;This line is never initialized, just declared.Exception in thread "main" java.lang.NullPointerExceptionat toPostfix.convert(toPostfixTester.java:47)at toPostfixTester.main(toPostfixTester.java:6)Line 47
lethalwirea at 2007-7-9 23:01:53 > top of Java-index,Java Essentials,Java Programming...
# 3
Curious as to why you think you can't trace it? Just put a try catch around your code, and from the catch block doe.printStackTrace();where e is the exceptoin caught
dmbdmba at 2007-7-9 23:01:53 > top of Java-index,Java Essentials,Java Programming...