Learn Throw keyword in Java | EasyTechCode

Published: 09 June 2022
on channel: BetaCode
77
9

#throwkeyword #javatutorial #java #javaprogramming #javabasic #javaforbeginners
Exception Handlingg:    • Learn Exception Handling in Java | Try and...  
In this video we learn about throw keyword.

Throw Keyword
_______________
User can throw exception directly.
It used to throw an exception explicitly.
We can throw either checked or unchecked exception.
We may set certain condition to throw an exception explicitly.
Syntax
new throw AnyException(“Name”);

For example:
new throw ArithmeticException(“Divide by Zero”)
We can throw only instance of Throwable or Sub
Classses of Throwable class

Example program
_________________
class sample_throw
{
public static void main(String a[])
{
int e;
e=Integer.parseInt(a[0]);
if(e==0)
{

throw new ArithmeticException("Exception Thrown by Easy CodeTech");

}
}
}
To run type
java sample_throw 0
The value zero is assigned throws command line argument.
The zero is assigned as
a[0]=0;
output
_______

Exception in thread "main" java.lang.ArithmeticException: Exception Thrown by Easy CodeTech
at sample_throw.main(sample_throw.java:10)

Other Video Link
________________
Exception Handling with multiple Catch block:    • Learn Exception Handling with Multiple Cat...  
How to compile and run java program in notepad
   • Learn How to Compile and Run Java |  EasyT...  
Program to print welcome to java:
   • Learn Simple Java Basics  
Inheritance Definition:    • Learn Inheritance in Java  | EasyTechCode  
Constructor in Java :    • Learn Java Constructor | EasyTechCode  
#JavaClassObject :    • Learn How to Create Object in Java |  Easy...  
Types of Constructor:    • Learn Java Constructor Types | EasyTechCode  
Overloading Methods:
   • Java Method Overloading Explained with Exa...  
Overriding Methods :    • Learn Java Overriding Method #java  
Super keyword :    • Learn Super Keyword | EasyTechCode  
Interfaces in Java:    • Learn Interface in Java | EasyTechCode  
Packages in Java:    • Learn Packages in Java | EasyTechCode  


On this page of the site you can watch the video online Learn Throw keyword in Java | EasyTechCode with a duration of hours minute second in good quality, which was uploaded by the user BetaCode 09 June 2022, share the link with friends and acquaintances, this video has already been watched 77 times on youtube and it was liked by 9 viewers. Enjoy your viewing!