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

R

rleroux

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
 
A

Andrew Thompson

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top