我在 NetBeans 中运行我的项目时遇到问题。
我认为这是一些路径问题,我之前用其他项目修复了它,但我仍然对此感到困惑。
这是我拥有的代码
public class TestStack
{
public static void main(String[] args)
{
double[] dblElements = {1.1, 2.2, 3.3, 4.4, 5.5};
int[] intElements = {1,2,3,4,5,6,7,8,9,10};
// Create a staqck of doubles & a stack of ints
Stack<Double> dStack = new Stack<Double>(5);
Stack<Integer> iStack = new Stack<Integer>();
// push elements onto the stack
PushDouble(dStack, dblElements);
PopDouble(dStack);
}
private static void PushInteger(Stack<Integer> stack, int[] values)
{
System.out.println("\nPushing elements onto stack of integers");
for (int i : values)
{
System.out.printf("%.1f ", i);
stack.push(i);
}
}
private static void PopInteger(Stack<Integer> stack)
{
try
{
System.out.println("\nPopping elements from stack of integers");
double value;
// Remove all elements from stack & display them
while(true)
{
value = stack.pop();
System.out.printf("%.1f ",value);
}
} // end of try block
catch(EmptyStackException E)
{
System.err.println();
E.printStackTrace();
} // end of catch block
}
private static void PushDouble(Stack<Double> stack, double[] values)
{
System.out.println("\nPushing elements onto stack of doubles");
for (double d : values)
{
System.out.printf("%.1f ", d);
stack.push(d);
}
}
private static void PopDouble(Stack<Double> stack)
{
try
{
System.out.println("\nPopping elements from stack of doubles");
double value;
// Remove all elements from stack & display them
while(true)
{
value = stack.pop();
System.out.printf("%.1f ",value);
}
} // end of try block
catch(EmptyStackException E)
{
System.err.println();
E.printStackTrace();
} // end of catch block
}
}
而我的错误是......
Error: Could not find or load main class teststack.TestStack
我应该怎么办?