permaculture playing cards*
The moose likes Beginning Java and the fly likes java.lang.exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java.lang.exception" Watch "java.lang.exception" New topic
Author

java.lang.exception

charishma gottumukkula
Greenhorn

Joined: Nov 06, 2006
Posts: 20
Can any one help me with the code which as a method that adds 2 Integer objects, returns the int result and that throws the exception java.lang.Exception if either parameter is null
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11499
    
  16

What have you written so far?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
charishma gottumukkula
Greenhorn

Joined: Nov 06, 2006
Posts: 20
I have just started learning java
I just want the sample code to execute that
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by charishma gottumukkula:
I have just started learning java...

Excellent! This is a good exercise to learn with. What do you think this method would look like?


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
charishma gottumukkula
Greenhorn

Joined: Nov 06, 2006
Posts: 20
The method which return int
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by charishma gottumukkula:
The method which return int

Okay, so that's...

What else? You said it should add the values represented by two Integer objects, and throw an exception if either of these references is null. Where would this go?
charishma gottumukkula
Greenhorn

Joined: Nov 06, 2006
Posts: 20
It should go into a result variable
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by charishma gottumukkula:
It should go into a result variable

Do you mean a local variable, like this?

Try putting the pieces together, and we'll help you get it working.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.exception