Answers for "print the last value of an array java"

2

how to print the last element of an array

var array = [1,2,3,4,5];
var last_element = array[array.length - 1];
console.log(last_element); //Expected Output: 5
Posted by: Guest on January-20-2021
0

last element array java

// Array of doubles
double[] array_doubles = {2.5, 6.2, 8.2, 4846.354, 9.6};

// First position
double firstNum = array_doubles[0]; // 2.5

// Last position
double lastNum = array_doubles[array_doubles.length - 1]; // 9.6
Posted by: Guest on January-07-2022

Code answers related to "print the last value of an array java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language