aspose file tools*
The moose likes Beginning Java and the fly likes Accessing return value of method within a method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Accessing return value of method within a method" Watch "Accessing return value of method within a method" New topic
Author

Accessing return value of method within a method

Eli Zuckerman
Greenhorn

Joined: Apr 19, 2010
Posts: 4
Suppose I have a class with a method like:

public void isWholeNumber()
{
checkIfWholeNumber();
}

where checkIfNumber() returns a boolean.

Is there a way to access that boolean value from another class?

Meaning could I do something like:
boolean i = ten.isWholeNumber().checkIfWholeNumber();


Thanks for the help
Marc Cracco
Ranch Hand

Joined: Mar 09, 2010
Posts: 77
    
    1
a) why not access checkIfWholeNumber() directly?

b) have isWholeNumber() return a boolean... which would be what people would expect from a is method...

c) why would you have the checking done in another method and not the one called, aren't you just passing the buck around???


SCJP 6 [ My stuff ]
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1614
    
  10

You can generally access any value from any class if you pass the references correctly.

The example you gave is a tad confusing. I'm not sure why you'd check to see if a number is whole twice in a row.


When you do things right, people won't be sure you've done anything at all.
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1614
    
  10

Maybe if you posted real code, we could help you better.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accessing return value of method within a method
 
Similar Threads
How to interpret := syntax in UML
booleanValue();
first()' method of ResultSetMetaData clas
Retrieving a value ..
Boolean vs boolean