Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Thuy Van Ngo
Thuy Van Ngo
3,289 Points

"returns a value" in programming

Could you, please explain more clearly what the term "returns a value" in programming" means? Thank you!

2 Answers

Travis Alstrand
Travis Alstrand
Treehouse Teacher

Hey there Thuy Van Ngo! Thanks for asking!

This was a concept that really gave me trouble when I first started, but with practice came a better understanding for me.

Sometimes in programming we need to be able to get a value that we aren't quite sure of yet, so we can't simply 'hard code' it in right away.

We could create a function that will, for example, do a math equation for us and return the end result to us. Then we can use that returned value for what we needed it for.

I'm not familiar with Java yet, but in the other languages I've learned so far I can declare a variable and set that equal to 'calling that function'. After the function runs and returns this value, that variable we declared will be equal to what that function has returned.

But simply put, it's a way of stating that a function is able to work some logic when it's called and return some kind of value to wherever it was called from. I hope that makes sense!