Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.



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,693 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