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

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,558 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.