Created
October 20, 2020 08:01
-
-
Save mmathys/1e1f064892dcae89bdecc797b3b97550 to your computer and use it in GitHub Desktop.
Swap Arrays
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Arrays; | |
class Main { | |
public static void main(String[] args) { | |
int[] array = new int[2]; | |
array[0] = 1; | |
array[1] = 2; | |
System.out.println("Vorher: " + Arrays.toString(array)); | |
/* Swap */ | |
int temp = array[0]; | |
array[0] = array[1]; | |
array[1] = temp; | |
System.out.println("Nachher: " + Arrays.toString(array)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment