I hope this is not a re-post. I couldn't find anything that answered my question so I decided to make this.
Say for example I have a
String [] arrayS = new String [2];
I assign the String arrays with words
arrayS[0] = Hello;
arrayS[1] = World;
Now I have a String [] method.
public static String [] change(String [] sArray, String newWord){
//Do Stuff
return sArray;
}
So when I return the method, with or without the assignment operator, I still get the same result. Example...
//This result
String newWord = Hi;
arrayS = change(arrayS, newWord); // With assignment operator.
for(String word:arrayS)
System.out.println(word);
//Is the same as this result
String newWord = Hi;
change(arrayS, newWord); // No assignment operator.
for(String word:arrayS)
System.out.println(word);
Is there any reason why it is like this? I always thought you must have an assignment operator to something when you return. But when I print out the arrayS, it gave me the same thing doing both method.