0

hello dears,
please can anyone correct my java error, when i run bellow java source code error cause as can not find symbol.

public class StackApp{
    public static void main (String arg[]) {


        StackX theStack   = new StackX(10);
        theStack.push(20);
        theStack.push(40);
        theStack.push(60);
        theStack.push(80);

        System.out.println("Value at top : " + theStack.peek());
        System.out.println("Is Full at begining : " + theStack.isFull());

        while (!theStack.isEmpty()) {
            long value = theStack.pop();
            System.out.print(value);
            System.out.print(" ");
        }
        System.out.println("");
        System.out.println("Is Full at begining : " + theStack.isFull());

    }
}

Edited by Ezzaral: Fixed code format.

3
Contributors
5
Replies
6
Views
4 Years
Discussion Span
Last Post by NormR1
0

Please post the full text of the compiler's error message that shows the source line and the error message.

0

this is my compilor error.

C:\Myjava>javac StackApp.java
StackApp.java:5: error: cannot find symbol
StackX theStack = new StackX(10);
^
symbol: class StackX
location: class StackApp
StackApp.java:5: error: cannot find symbol
StackX theStack = new StackX(10);
^
symbol: class StackX
location: class StackApp
2 errors

C:\Myjava>

0

If the class StackX is not in the same directory as this file, you will need to import the StackX class to reference it.

0

Find the definition for the StackX class and put it on the classpath so the javac program can find it.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.