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

Discussion in 'Java' started by rleroux@telus.net, Jan 28, 2007.

  1. Guest

    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
     
    , Jan 28, 2007
    #1
    1. Advertising

  2. On Jan 28, 5:00 pm, 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.
     
    Andrew Thompson, Jan 28, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. santanuc
    Replies:
    0
    Views:
    520
    santanuc
    Jan 29, 2005
  2. Shiperton Henethe
    Replies:
    9
    Views:
    2,691
    Duende
    Nov 26, 2004
  3. Chris Bardon

    Web Service Calling a COM object-throws exception.

    Chris Bardon, Jun 8, 2004, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    125
    Michelle Hlaing
    Feb 28, 2005
  4. gane
    Replies:
    2
    Views:
    232
    Murtaza
    Jul 23, 2006
  5. Jon-Paul Dobson
    Replies:
    1
    Views:
    116
    Jim Higson
    Sep 15, 2004
Loading...

Share This Page