Answers for "changing the elements of an array using a for loop java"

0

changing the elements of an array using a for loop java

int[] anIntArray = new int[6];
/*
	This is for when you want to increment the contents of an array 
    using a for loop.
*/
for (int i = 0; i < anIntArray.length; i++) {
    anIntArray[i]++;                      
}

//=============================================================================

String[] aStringArray = new String[6];
/*
	This is for when you want to change the contents of an array
    using a for loop
*/
for (int i = 0; i < aStringArray.length; i++) {
	aStringArray[i] = 'The value it should change to'; //Should be compatible with the array type
}
Posted by: Guest on October-24-2020

Code answers related to "changing the elements of an array using a for loop java"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language