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 / May 2006

Tip: Looking for answers? Try searching our database.

How to get a return type?

Thread view: 
Tom - 30 May 2006 17:04 GMT
Hi,

I have a question. I have two methods below.

public void A() {
    //some code

    return;
}

public boolean B() {

    //I want to call A(), but how can I return something like true, or false

}
Eric Sosman - 30 May 2006 17:09 GMT
Tom wrote On 05/30/06 12:04,:
> Hi,
>
[quoted text clipped - 11 lines]
>
> }

   Simplicity itself:

    public boolean B() {
       A();         // calls A()
       return true; // returns "something like" true or false
    }

If you don't find this answer satisfactory, please explain
your goals in more detail.  For example, describing why this
answer doesn't meet your needs might be a good start.

Signature

Eric.Sosman@sun.com

Chris Smith - 30 May 2006 17:13 GMT
> I have a question. I have two methods below.
>
[quoted text clipped - 9 lines]
>
> }

I'm not sure what you're asking.  A() can not return anything, since
it's declared void.  B() can return something.  If you want B to call A
and then return something, it looks like this:

   public boolean B()
   {
       A();
       return true;
   }

Incidentally, it would be better to name those methods a and b, not A
and B.  Method names in Java begin with lower-case letters.

Signature

www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation



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



©2008 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.