This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accessing return value of method within a method

 
Eli Zuckerman
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 80
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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???

 
Janeice DelVecchio
Saloon Keeper
Posts: 1807
12
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Janeice DelVecchio
Saloon Keeper
Posts: 1807
12
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe if you posted real code, we could help you better.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic