Java exception | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Java exception

why my code isnt catching exception public class Program { public static void main(String[] args) { try{ String x=5; System.out.println(x); } catch(Exception e){ System.out.println("Errir"); } } }

28th May 2020, 5:57 PM
Abdul Majeed Faraz
Abdul Majeed Faraz - avatar
5 Answers
+ 1
Yeah, an error usually means an unexpected (mis)behavior of an application. An exception is either part of error handling or error prevention.
28th May 2020, 6:13 PM
Sandra Meyer
Sandra Meyer - avatar
+ 2
oh ok thanks for the answer
28th May 2020, 6:14 PM
Abdul Majeed Faraz
Abdul Majeed Faraz - avatar
+ 1
This bug leads to a compiler error, which prevents from building any executable software.
28th May 2020, 6:00 PM
Sandra Meyer
Sandra Meyer - avatar
+ 1
are error and exception different things?
28th May 2020, 6:11 PM
Abdul Majeed Faraz
Abdul Majeed Faraz - avatar
+ 1
You're welcome
28th May 2020, 6:15 PM
Sandra Meyer
Sandra Meyer - avatar