Answers for "java intercambiar la posicion de valores de un array"

-1

java intercambiar la posicion de valores de un array

public class ArrayMethods {

private int[] values;
public ArrayMethods(int[] initialValues) {
values = initialValues;
}
public void swapFirstAndLast() {
int lastvalplace = values.length;
int firstval = values[0];
values[0] = values[lastvalplace];
values[lastvalplace] = firstval;
}

public static void main(String[] args) {
ArrayMethods initialValues = new ArrayMethods(int[] 50, 32, 4, 9, 2);
swapFirstAndLast = new swapFirstAndLast(values);
}

}
Posted by: Guest on March-15-2021
0

java intercambiar la posicion de valores de un array

int lastElement = values[values.length-1];
values[values.length-1] = values[0];
values[0] = lastElement;
Posted by: Guest on March-15-2021

Code answers related to "java intercambiar la posicion de valores de un array"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language