Will Java have a way for non-library developers to use extension methods?
extension-methods, java
Solution
Java does not have this feature, nor is it likely to have it anytime soon.
Groovy however does have a very similar feature, and it also runs on the JVM. Perhaps that's an option.
Problem
C#'s extension methods are great for adding syntactic sugar. Java extension methods are great for allowing library developers to add methods to their interfaces. I am a non-library Java developer and know I will reap a lot of benefits from getting new functionality from libraries, but I would still like to have the syntactic sugar capabilities of C# extension methods. Is this, or will this be possible in future versions of Java? eg: I would like to add methods to the String class... ``` String data = StringUtils.capitalize("abcd"); // instead of this String data = "abcd".capitalize() // I would like to do this ``` Please don't focus on this particular example, I am only showing the class of functionality I want to be able to achieve.