I need to add a method to the String class in an Android app so I can call it like
String myStr;
x = myStr.myNewMethod(3);
I don’t have any idea how I could do this in Java.
ps I do not want to create a Subclass of String. This would mean that I need to do coercion all over and/or declare my Strings as a new Class.
Many thanks
Without creating either a subclass (inhertance) or a wrapper class (composition) you cannot do this.
Just write a static helper method that takes a string and whatever other parameters you need.