I have declared a class main where I am calling the main function. I have commented the main function in Class Stack as I am calling the push and pop functions in the class Main. I have put up the code and the error I am facing.
CODE:
public class Stack {
//public static void main(String[] args) {
// TODO Auto-generated method stub
static final int max = 10;
int top = -1;
int a[]= new int[max];
static void push(int data)
{
if (top>=max -1)
System.out.println("OVerflow");
else
a[++top]= data;
}
static int pop()
{
if (top<0)
System.out.println("Empty Stack");
else
{int x = a[--top];
return x;
}
}
}
//}
class main {
public static void main(String[] args) {
Stack s = new Stack();
s.push(10);
s.push(20);
s.pop();
s.push(9);
s.pop();
for (i =0; i< 10;i++)
{
System.out.println(a[i]);
}
}
}
ERROR:
Error: Main method not found in class Stack, please define the main method as:
public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application