I am trying to use the string after I passed it through my cleanUp function. When I return the arguments it no longer keeps the same value.
My initial strings have punctuations. I pass the strings to a method to clean up the punctuations. I return the modified strings back to my main method. I print out the modified string but my results have returned to the original value of the string.
public class test{
    public static void main(String[] args){
        String str1 = "this-is.first:sentence/.";
        String str2 = "this=is.second:sentece.";
        String[] arr = cleanUp(str1, str2);
        for (String string : arr){
            System.out.println("string after cleanup()" + string);
        }
    }
    public static String[] cleanUp(String str1, String str2) {
        String[] arr = {str1, str2};
        for (String string : arr){
            string = string.replaceAll("\\p{Punct}","");
            System.out.println("string cleaned:" + string);
        }
        return new String[] {str1, str2};
    }
}
Current Output:
string cleaned: this is first sentence  
string cleaned: this is second sentece 
string after cleanup(): this-is.first:sentence/.
string after cleanup(): this=is.second:sentece.
Expected Output:
string cleaned: this is first sentence  
string cleaned: this is second sentece 
string after cleanup(): this is first sentence
string after cleanup(): this is second sentece
 
     
    