Generics is one of the best things that happened to Java. Anyone who has worked with Java during its pre-JDK5 era can attest to that. For new developments, it has drastically reduced the amount of written codes and provided compile-time type checking using Generic Types. However, there are some things you cannot do with Generics Types.
Rust – How to Declare and Initialize an Array
Rust is a strange language for some. However, it is a fun programming language to play (or work) with. When we need arrays in Rust, we declare and initialize an array simultaneously with size and default values. Declare And Initialize
Rust – Display Contents of Array, Tuple, HashMap and Vector
When using collection types, we sometimes do not want to use loops to display each value. For example, in Rust, we can display the content of an Array, Tuple, HashMap (Map), or Vector without loops using the Debug trait. Rust
Kotlin – Check if a certain values exists in a list
This post shows examples of codes to check if certain values exists in a list.
Array-backed Lists in Java
In Java, there are these array-backed lists that are generated when you convert arrays to lists using Arrays.asList(…). The list and the array objects point to the same data stored in the heap. Changes to the existing contents through either the list or array result to changing the same data.
Java – Copy array by range
This post will show you how to copy a subset elements of an array by range. For example, copy elements from index 3 to 4 (exclusive). The range values work in the same way as the String’s substring method.
Java Compare Multidimensional Arrays Of Reference Types
This post shows how to compare two multidimensional arrays of reference types in Java. The codes will examine if they are the same in terms of element values and their locations. For example, we want to compare a modified array
Check if a value is in an Array in JavaScript
Given an array of strings, we want to know if a particular string value is in that array. Here we’ll use the Array object’s .indexOf function.
JavaScript Arrays with Elements of Different Data Types
Array with different types of data? Weird stuff! Generally, an array is collection of similar items. In Computer Science 101, this means the items are of the same data type. We have an array of integers, boolean values or strings. But in JavaScript, arrays can have elements of different types.
Type Checking in JavaScript
Okay, JavaScript is a loosely-typed language, which means you do not declare the data type of a variable explicitly. In a basic variable assignment expression, e.g., var i = 4;, the value that assigns to the variable determines the data type of the variable. As you assign different types of data to the same variable, its data type changes as well. Given the nature of JavaScript, finding out what data type a variable represents before using it is very important.