This post summarizes 5 different ways of printing an array in Java.
Array
System.arraycopy() vs. Arrays.copyOf() in Java
If we want to copy an array, we can use either System.arraycopy()
or Arrays.copyOf()
. In this post, I use a simple example to demonstrate the difference between the two.
How to Check if an Array Contains a Value in Java Efficiently?
How to check if an array (unsorted) contains a certain value? This is a very useful and frequently used operation in Java. It is also a top voted question on Stack Overflow. As shown in top voted answers, this can be done in several different ways, but the time complexity could be very different. In the following I will show the time cost of each method.