+ 1

Multiple exceptions: what does static keyword mean here ?

public class Program { static int div(int a, int b) throws ArithmeticException { if(b == 0) { throw new ArithmeticException("Division by Zero"); } else { return a / b; } } public static void main(String[] args) { System.out.println(div(42, 0)); } }

26th Jan 2022, 4:55 PM
A Rahman Mamnoon
A Rahman Mamnoon - avatar
1 Respuesta
+ 5
There is no relation with static and exceptions. Both are different things. static means store data in memory when jvm start. static method does not need instance means you can access without any instance of class.
26th Jan 2022, 5:35 PM
A͢J
A͢J - avatar