Solved

Is there anyway I can use ‘use case’ for error handling?

Posted on 2004-04-16
7
208 Views
Last Modified: 2010-03-31
Is there anyway I can use ‘use case’ for error handling?

I am sure I have read some where that you can use it for example if error the case1 etc, can this be done in java? can anyone show me any examples if it can be done?
0
Comment
Question by:pigmentarts
7 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 10846751
Maybe you're thinking about this kind of thing?:

catch(Exception e) {
    if (e instanceof IOException) {
        // do something
    }
    else if (s instanceof ClassCastException) {
        // do something different
    }
}
0
 
LVL 92

Accepted Solution

by:
objects earned 125 total points
ID: 10846763
try
{
    // your code here
}
catch (IOException ex)
{
   // handle IOException here
}
catch (ClassCastException ex)
{
   // handle ClassCastException here
}
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10846802
You *could* use a case statement but it would be highly artificial and not a good idea
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 92

Expert Comment

by:objects
ID: 10846812
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10846814
it was just i has seen it somewere i wanted to see if it was just in my head or not. thanks.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10846818
Please explain the reason for accepting that particular answer pigmentarts
0
 
LVL 15

Expert Comment

by:Javatm
ID: 10846833
Hi;

Error handling can delt in many ways like if / else & case statements but the real
way you do that in Java is by using try / catch & finally :

try
{
    if(Your Thing) {
    }
    else {
    }
}
catch (YourException e)
{
   // handle your exception here !
}

Here is a tutorial :
http://java.sun.com/docs/books/tutorial/essential/exceptions/

Hope that helps . . .
Javatm

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
couple of eclipse 5 46
null output 3 35
How do I remove an object from a 3 40
How to configure empty element in XML Document parser? 15 36
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question