File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Method visibility inside a try block Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Method visibility inside a try block" Watch "Method visibility inside a try block" New topic
Author

Method visibility inside a try block

Mary Taylor
Ranch Hand

Joined: Sep 11, 2000
Posts: 327
Several times I have run into this issue. I want to call another method in the same class. I cannot do this when inside a try block. I can send some sample code, but I think perhaps it is just a general question that does not need code to answer. The error message is the compiler cannot resolve symbol (name of method I wish to call).
Thanks.
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
I think you had better post some example code. AFAIK, you can call any method you want from inside a try block. What prompted the claim that you can't? Have you had compiler errors when you tried it before?


Java API Documentation
The Java Tutorial
Mary Taylor
Ranch Hand

Joined: Sep 11, 2000
Posts: 327
As long as it's not something I didn't know about visibility and try blocks, I'll look for the problem in the code. Thanks.
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
Best to post the code, Betty. My first guess would be that you left out an import statement, or are misspelling the name of a class or method.


Ron Newman - SCJP 1.2 (100%, 7 August 2002)
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
...or maybe the method name was spelled correctly, but the parameter list wrong.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
That at least will get you a more useful error message. Something like:
foo(int,int) in MyClass cannot be applied to (java.lang.String)
Mary Taylor
Ranch Hand

Joined: Sep 11, 2000
Posts: 327
Thanks, guys, but at least this time I think it was a case sensitivity error. ( on my part! )
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Originally posted by Ron Newman:
That at least will get you a more useful error message. Something like:
foo(int,int) in MyClass cannot be applied to (java.lang.String)

Sun's Java v1.4 compiler does give such a nice error message, but other compilers, such as the v1.3 compiler that shipped with JBuilder 7, just give the "method not found" or "no such method" error message.
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
The error message I posted is from the 1.3.1 compiler on MacOS X.
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Yes, yes... I've been told repeatedly that Macs are better.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Method visibility inside a try block