What do you want to save?
Add Code snippet
New code examples
-
Javascript 2022-03-21 05:40:05
Using Array.isArray() method and Array.length
// create empty array in javascript let empty_array = [] // check empty is Array and then check array length if(Array.isArray(empty_array) && empty_array.length){ // if empty_array is a array and empty_array has a length console.log("Ar... Add solution -
Ruby 2021-11-14 12:17:24
ruby .first
# Returns the first element, or the first n elements, of the array. # If the array is empty, the first form returns nil, # and the second form returns an empty array. a = [ "q", "r", "s", "t" ] a.first #=> &... Add solution -
Java 2021-09-26 18:19:03
exception in thread "main" java.lang.indexoutofboundsexception: index 1 out of bounds for length 1
0 means you are trying to access index 0 which is invalid, which in turn means the array is empty. String[] names = new String[0]; // thats the problem String[] names = new String[somelength];//this is true usage Add solution