Tag: Array
How to convert Array to List in Java ?
This article will explain how to convert a simple array to list in Java . How to convert Array to List in Java ? The Java’s array class provides necessary methods to convert the array to the List using the asList method. Below is a sample code snippet demonstrating the usage of the Arrays.asList method to convert array to List.
How to Create an Empty array without defining the size in C# ?
When we create an array in C# , we tend to define the size of the array as shown below. Can we create an array without defining the size ? The best option in this scenario is to use the collection. You can use the Generic List which allows you to add as many items as possible and then you can use the ToArray method…
How to fill an array with default values in Java ?
If you want to fill an array with default values in Java , you can use the Arrays.fill method to do it . The Arrays.fill method lets the developers fill the empty array with the default values. How to fill an array with default values in Java ? Below is an example of the usage of the Arrays.fill method in java .
Concatenate or Join a string Array using LINQ in C#
Want to join the items inside the string array say with, delimiter using LINQ in C#? It’s pretty easy. Below is a sample code snippet demonstrating in easy steps on how to concatenate a string array using LINQ in C#? Concatenate or Join a string Array using LINQ in C#
How to sort an array using Comparator in Java ?
The Arrays.sort method in java lets the developers to sort an array of objects. The sort method also accepts the comparator object which can contain the sorting logic. How to sort an array using Comparator in Java ? Below is a sample code snippet demonstrating the usage of the Arrays.sort method with the comparator.
How to clear the array in JavaScript?
There are times when you want to clear the array that you have already defined with entries and reuse it. For example Arry = [109,625,200]; How to clear the array in JavaScript? One of the easiest way to clear the array contents in JavaScript is setting the Array Length t0 0.
How to copy array and increase size dynamically in Java ?
Below is a sample code snippet in Java demonstrating the steps to copy the array elements to a new array and increase the size dynamically. The program using the Arrays.copyOf method which lets the developers to create new array with a new size as well as copy the content of the old array to it at the same time. How to copy array and increase…
How to Convert a Number to Bytes Array in C# ?
To Convert a number to a byte array , the developers can use the BitConverter.GetBytes method which returns array of bytes. How to Convert a Number to Bytes Array in C# ? Below is a sample code snippet demonstrating how to convert a Number to Byte Array in C# .
How to get the Number of Elements in an MultiDimensional Array in C# ?
In one of the previous articles , we demonstrated the usage of the Length property of the array in C# to get the number of elements in it. In this post , lets have a look at getting the number of elements in the multi-dimentional array in C#. How to get the Number of Elements in an MultiDimensional Array in C# ? If you wanted…
How to find the Max and Min value from an Integer Array ?
To find the Max and Min Value from an Integer Array , one could use the functions Max() and Min() defined in the array object.
How to use array Rank in C# ?
In C# , the Rank property of the array is is used to get the rank of the array. In simple terms , rank refers to the number of dimensions of the array. How to use array Rank in C# ? You can get the number of dimensions of the array using the Rank property of the array. For instance , the Rank property of…
How to Declare Array of Objects in C# ?
Do you want to declare an array of objects in your C# application ? . Below is a sample code snippet that demonstrates how to declare an integer array in C#. How to Declare Array of Objects in C# ?
Using HashSet to remove duplicates from array in C#
If you want to remove duplicates from an array in C# , one of the options is to use HashSet as shown below. How to remove duplicates from an array in C# using HashSet?
How to Compare two arrays in C# ?
Two arrays can be compared in C# using the Enumerable.SequenceEqual method . The Enumerable.SequenceEqual method in C# returns a boolean value indicating if both the arrays are equal or not. How to Compare two arrays in C# ? Below is an example of comparison of two arrays in C# using the Enumerable.SequenceEqual method.
How to fill an array with default values in C# ?
To fill an array with the default values in C# , you can use the Enumerable.Repeat method to do it. How to fill an array with default values in C# ? Below is a sample code illustrating the usage of the Enumerable.Repeat method to fill an array with default values.
How to get the Number of Elements in an Array in C# ?
You can use the Length property of the array to return the number of elements in it. Note that once the array is created , you cannot change its length. How to get the Number of Elements in an Array in C# ? Here’s a code snippet demonstrating the usage of the Length property of the array to get the number of elements.
How to sort an array in C# ?
If you want to sort an array in C#.NET , you can use the Array.Sort method to do it. How to sort an array in C# ? Below is a sample code snippet demonstrating the usage of the Array.Sort method to sort an array in C#.
How to sort an array in Java ?
If you want to sort an array in Java , you can use the Arrays.sort utility method to do it. How to sort an array in Java ? Below is a sample code snippet demonstrating the usage of the Arrays.sort utility method to sort an array in java.