Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > calling a method with 'throws IOException' from another method in the same class

Reply
Thread Tools

calling a method with 'throws IOException' from another method in the same class

 
 
rleroux@telus.net
Guest
Posts: n/a
 
      01-28-2007
I have a method defined as follows in a class:

public static void salary_proj_accept()throws IOException
{
statements;
}

Later in the same class I have another method

public void salaryPay(float startsalary, float salaryincrease, int
percentincreasefro, int percentincreaseto, int yearto)
{


I'm trying to call the first method by:
salary_proj_accept();
}

However when I do so, I'm told I need to throw an exception...so I
replace with:
salary_proj_accept()throw IOException

When I do, I then get:
Salaryprojection.java:89: ';' expected
salary_proj_accept()throws IOException;
^
Salaryprojection.java:89: not a statement
salary_proj_accept()throws IOException;

Is there a way that I can call my first method?

Tnx

 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      01-28-2007
On Jan 28, 5:00 pm, (E-Mail Removed) wrote:
> I have a method defined as follows in a class:
>
> public static void salary_proj_accept()throws IOException
> {
> statements;
> }
>
> Later in the same class I have another method
>
> public void salaryPay(float startsalary, float salaryincrease, int
> percentincreasefro, int percentincreaseto, int yearto)

// declare it throws an IOE
throws IOException

> {
>
> I'm trying to call the first method by:
> salary_proj_accept();
> }
>
> However when I do so, I'm told I need to throw an exception...

....
> Is there a way that I can call my first method?


try {
salary_proj_accept();
catch (IOException ioe) {
ioe.printStackTrace();
}

Note
- Please follow the common class/method/attribute
conventions for names, e.g. salaryProjAccept()
when posting code
- comp.lang.java.help is a good group for those
starting Java.

HTH

Andrew T.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
injecting an instance method into another class' class method Chuck Remes Ruby 3 08-12-2010 07:15 PM
Calling method from another class Kostas Lps Ruby 14 08-27-2009 03:28 PM
Adding method from one class to another class or to instance ofanother class marekw2143 Python 3 07-25-2009 08:33 PM
why a class can't access protected method from another class in thesame package,the method is interited from the ohtner class from differntpackage? junzhang1983@gmail.com Java 3 01-28-2008 02:09 AM
Calling method from another class and SQL select max id issue teser3@hotmail.com Java 2 10-02-2007 10:27 PM



Advertisments