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.

Java

Sam Asghar
Sam Asghar
800 Points

Methods

So if IgnoreCase and printf or toLowerCase are methods. Craig says that i can create methods myself.So that means after i create a method i can use it the same way like:

System.out.myOwnCoolPrintfTurboChargedMethod2000("Cheese is life");

Might be a dumb question but i'm getting a bit confused. Does all of this mean i can create my own output system and ditch "console.printf" and "System.out"?

I like the way you think bro!

1 Answer

andren
andren
28,538 Points

Yes, more or less. It's not common or that simple to add methods to existing classes like out. But creating your own class and attaching a static method to it is pretty simple. So you could definitively setup something that allowed you to type: MySuperCoolCustomClass.myOwnCoolPrintfTurboChargedMethod2000("Cheese is life") and have that work.

You could in theory create your own output system, but do keep in mind that the various print methods do some pretty complex stuff behind the scenes, creating your own output system while certainly possible in theory would require quite a bit of coding knowledge.

I'm guessing you are relatively early on in the Java courses currently so you haven't been thought too much about classes, methods, inheritance and the myriad of other complex Java systems. But by the time you are through with the various Java courses here on Treehouse you should be more than capable of setting up custom classes and the like.