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



I have explored some other programming languages and In those languages we could create function to group our code and call them later. Is that possible in java? I am not talking about object methods.

Muhamed Asil
Muhamed Asil
7,453 Points

in Java you can call a function, object or class. is it useful?

3 Answers

Simon Coates
Simon Coates
28,694 Points

Historically not really. But you could create a static function that wouldn't require an object to call it. Java 8 has something called a lambda function that people discuss in terms of being functional. But historically java is object oriented and loose functions tend to be associated with a different programming paradigm. (it's confused a little since some OO languages - PHP for instance - aren't pure OO, making the conceptual difference murkier).

It's not exactly the same, but it sounds like an Interface might be what you are looking for.

Thanks guys