Garmaine Staff asked 1 year ago
This question already has answers here:”>Java variable inside a loop [duplicate] (4 answers)
Closed 5 hours ago.

I have the following piece of code in java.

String[] words = {"House","School","Name"} ;
for(int i = 0; i < words.length; i++){
            int randomChars = random.nextInt(lengthOfText);
            System.out.println("randomChars" + randomChars);
            char[] currentChars = words[i].toCharArray();

I have learned that an array is not dynamic. The length is static. But here in this code the length of the char array increase and lastly decrease. Can someone explain me this behavior?