Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
rleroux@telus.net - 28 Jan 2007 06:00 GMT
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
Andrew Thompson - 28 Jan 2007 06:30 GMT
On Jan 28, 5:00 pm, rler...@telus.net wrote:
> I have a method defined as follows in a class:
>
[quoted text clipped - 7 lines]
>    public void salaryPay(float startsalary, float salaryincrease, int
> percentincreasefro, int percentincreaseto, int yearto)
 // declare it throws an IOE
 throws IOException

>         {
>
[quoted text clipped - 3 lines]
>
> 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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.