I would like to know if there is, in Java, a function that can prefix a defined String to the beginning of every String of an array of Strings.
For example,
my_function({"apple", "orange", "ant"}, "eat an ") would return {"eat an apple", "eat an orange", "eat an ant"}
Currently, I coded this function, but I wonder if it already exists.
Nope. Since it should be about a three-line function, you’re probably better of just sticking with the one you coded.
Update
With Java 8, the syntax is simple enough I’m not even sure if it’s worth creating a function for: