If you notice in this block of code. When an array is passed to a method. It's contents are modified when the method returns.
Code:class ArrayExample{ public static void main(String[] args){ String[] s = {"Hello","Whats's","up?"}; printStrings(s); for(int i = 0; i < s.length; ++i){ System.out.println(s[i]); } } static void printStrings(String[] s){ for(int i = 0; i < s.length; ++i){ System.out.println(s[i]); } s[2] = "down"; } }




Reply With Quote