Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


sushant
Setup file
1 Answer(s)      5 years and 5 months ago
Posted in : Java Beginners



Advertisement
View Answers

July 20, 2009 at 3:43 PM


Hi Friend,

Whenever we want to force an exception then we use throw keyword. The throw keyword is used to force an exception. It can also pass a custom message to your exception handling module. Moreover throw keyword can also be used to pass a custom message to the exception handling module i.e. the message which we want to be printed. For instance in the above example we have used -

throw new Exception ("can't be divided by zero");

Whereas when we know that a particular exception may be thrown or to pass a possible exception then we use throws keyword. Point to note here is that the Java compiler very well knows about the exceptions thrown by some methods so it insists us to handle them. We can also use throws clause on the surrounding method instead of try and catch exception handler. For instance in the above given program we have used the following clause which will pass the error up to the next level -

static int divide(int first,int second) throws Exception{

For more information,please visit the following link:

http://www.roseindia.net/java/exceptions/how-to-throw-exceptions.shtml

Thanks


Related Tutorials/Questions & Answers:
Creating a setup file
Creating a setup file  How to create a setup file in tomcat as done in visual studio... could plz tell me as early as possible
Setup file - Java Beginners
Setup file  Hello sir ,how i can make Java Programs Set up File ,Please give me steps to make that. & What is the difference between Throw and Throws,Can U give me Simple code to Differ Throw and Throws ?  Hi Friend
Advertisements
Setup in Java
Setup in Java  Hello I want to know that how to create make setup in java of a java program or jFrame applicatio or Applet.Plz give answer ASAP. Thanks & Regards Sunil Kumar
Setup validator framework in Struts
Setup validator framework in Struts  How to Setup validator framework in Struts
installation and setup problem - Java Beginners
installation and setup problem  Hi, Iam new to java.Can any one tell me about how to install tomcat5.5 and set up in my windows xp operating system in detail? Thanks in advance
Setup Hibernate Environment
Setup Hibernate Environment - Learn how to setup Hibernate Development... the file hibernate-release-4.2.8.Final.zip. It includes the libraries... the downloaded file (hibernate-release-4.2.8.Final.zip) into a directory and then unzip
EJB Deployment how to create a simple ejd session bean and how to do project setup
to do project setup...? please help me i am getting difficult
File
File  How to create .Exe file in jana
file
file  how can copy the information in the file to the string?   Store file data into String
file
file  Could anyone please help me to write a code that does the following: Opens a file named MyName.txt, reads the first line from the file and displays it, and then closes the file. Thank you so much
file
file  Hi,what can delet some of the information of the file
file
file  Hi,how can delet some of the information of the file
file
file  how can add the information to the graphic file
FILE
FILE  There is a file named Name.txt that contains information related to appliances.I want to read the contents of this file and I used the code... args[]) { try { File file=new File("Name.txt"); FileReader f=new FileReader(file
File
File   How to find all files in our local computer using java
file
file  hi i want read special line of file. what am i doing ? I write... read data from file. please help me! void maketree(BtNode root,int i) throws... at the following link: Read specific line from file
To make java exe or runnable file
To make java exe or runnable file   Helo sir i make a java application.I need to help how run application direct in pc i.e how it packaged, .exe file or setup file
Setup MySQL Database
Setup MySQL Database          In this section we will create database and table into MySQL database. Table created here will be used in sample application
File path for jar file
File path for jar file  Hi Experts, I have created one eclipse... jar file of that application, unfortunately it is giving the error that resource not found for the template file. Also I had tried to get that path from user
File I/O
File I/O  i have a problem i am trying to print on a new line every... lifecycle management Setup and teardown of services behind a MapView Creating... usually do.Activity responsibilities include: Activity lifecycle management Setup
EAR file
EAR file   What is the EAR file
String file in to word file in java
String file in to word file in java  How to convert a String format notepad file into Ms word file in java
Convesion of txt file to doc file.??????
Convesion of txt file to doc file.??????  how to convert text file to doc file using java
File manipulations
File manipulations  how to count number of words in a file
File manipulations
File manipulations  how to read input to a file from console
 

 

 

DMCA.com