Если top == size, он ловит ошибку и отображает сообщение, что стек заполнен, не останавливая l oop. Как это сделать? Но мой код ниже не остановится
вот мой код ...
while(ask==true){
try{
String input=JOptionPane.showInputDialog("1.Push? Just type yes 2. Pop? just type no");
if(input.equals("yes")){
String element=JOptionPane.showInputDialog("Enter Element");
int num=Integer.parseInt(element);
top++;
arr[top]=num;
System.out.println("Insertion was successful:"+" "+arr[top]);
// isFull();
}else if(input.equals("no")){
pop();
}if(input.equals("exit")){
getStack();
top();
ask=false;
}
}catch (ArrayIndexOutOfBoundsException e){
System.out.println("full");
}
}