Swapping Elements

Run Settings
LanguageJava
Language Version
Run Command
class Main { public static void main(String[] args) { int[] elements = {1, 2, 3, 4, 5}; /*Put your code here to swap the first element with the last*/ int temp = elements[0]; elements[0] = elements[elements.length-1]; elements[elements.length-1] = temp; for(int i = 0; i < elements.length; i++) { System.out.println(elements[i]); } } }
Editor Settings
Theme
Key bindings
Full width
Lines