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

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 Pages:
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
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
Hibernate Relationships - Settingup database
- Setting up database: In this section we will setup the database... setup the database and create the MySQL schema. We will use the Hibernate... is the property defined into hibernate.cfg.xml  file:   <property
Downloading Struts & Hibernate
and setup the development environment. Downloading Hibernate Hibernate is free....zip. Save downloaded file into your hard disk. Downloading Ant Ant is a free... of mysql jdbc driver. Copy the JDBC driver file (mysql-connector-java-3.0.16-ga
Damn Small Linux 2.3 RC1 has been released now
Damn Small Linux 2.3 RC1 has been released now New check and prompt to save APSFILTER printer setup; new check and prompt to save wireless setup; new MyDSL... and viewing (Xpaint, and xzgv), Xpdf (PDF Viewer), emelFM (file manager), Naim
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
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
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
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  how can add the information to the graphic file
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 to find all files in our local computer using java
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
Writing Hibernate Configuration Files
the database setup and created required table and populated with the data... File Hibernate configuration file (hibernate.cfg.xml) is used to provide... of Hibernate configuration file.  Here is the code of our Hibernate
Writing Hibernate Configuration Files
the database setup and created required table and populated with the data. In this section... need following Hibernate configuration files: Hibernate Configuration File Hibernate configuration file (hibernate.cfg.xml) is used to provide the information
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
Developing Simple Struts Tiles Application
how to setup the Struts Tiles and create example page with it. What is Struts... application: Add the Tiles Tag Library Descriptor (TLD) file..., run and test application. Add the Tiles TLD to web.xml file Tiles can can
how to create a set up file of java web application
in this case I would like to make my product as a setup file,where my client can...how to create a set up file of java web application  I have already... if any one knows how to do the java web application as a set up file, please help
how to create a set up file of java web application
to my client, so in this case I would like to make my product as a setup file,where...how to create a set up file of java web application  I have already... file, please help me. I can't give any sample codes according to my company norms
how to create a set up file of java web application
in this case I would like to make my product as a setup file,where my client can...how to create a set up file of java web application  I have already... if any one knows how to do the java web application as a set up file, please help
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
EAR file
EAR file   What is the EAR file
Convesion of txt file to doc file.??????
Convesion of txt file to doc file.??????  how to convert text file to doc file using java
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
File manipulations
File manipulations  how to read input to a file from console
File manipulations
File manipulations  how to count number of words in a file
File manipulations
File manipulations  how to read the contents from one file and move the contents to another file
EAR file
EAR file   What is the EAR file ?   An EAR file is a standard JAR file with an .ear extension, named from Enterprise ARchive file. A J2EE application with all of its modules is delivered in EAR file
File Operations
File Operations  Please i would like to know if it is possible to read from a file and write to the same file at the same time
WAR file
WAR file  What is a WAR file
File Transfer
File Transfer  How to create a file in server side using java swing
File Upload
File Upload  when i execute the image upload to mysql database it shows an exception that file path cannot be found
deleting file
deleting file   how to delete a file from a folder and its corresponding path in database using a servlet
JSP File
JSP File  Hi, What is JSP File? How to create JSP file? Thanks   Hi, JSP file is simple text file with .jsp extenstion. You can run JSP file on tomcat server. Read more at JSP tutorials section. Thanks
JAR FILE
JAR FILE  WHAT IS JAR FILE,EXPLAIN IN DETAIL?   A JAR file... and applications. The Java Archive (JAR) file format enables to bundle multiple files into a single archive file. For more information, visit the following
String file in to word file in java
String file in to word file in java  how to convert a String format word file into Ms Word file using java? please can anyone of you help me
on file system
on file system  how to maintains record in a file using java and how to create objects to each record.   Hi, Please read Java Write file tutorial. Regards Deepak

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.