Try this
public static void s() {
System.out.println(s);
s--;
if(s!=0)
{
//I want the program to stop here since s is already 0.
System.out.println(s);
}
}
1
solved Java exit while loop from called method [duplicate]