Ankith Reddy has Published 1070 Articles

Java instanceof and its applications

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 15:25:56

444 Views

instanceof operator is used to check the type of object passed. Following rules explain the usage of instanceof operator in Java.instanceof operator returns true for the object if checked against its class type.instanceof operator returns false for the object if checked against its type which is not in its hierarchy.instanceof ... Read More

With CSS set the element to retain the style values that is set by the first keyframe

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 15:23:03

82 Views

To set the elements to retain the style values set by the last keyframe, use the animation-fill-mode property with the backwards value.ExampleLive Demo                    div {             width: 150px;             ... Read More

Iterator in Java

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 15:13:29

325 Views

Often, you will want to cycle through the elements in a collection. For example, you might want to display each element. The easiest way to do this is to employ an iterator, which is an object that implements either the Iterator or the ListIterator interface.Iterator enables you to cycle through ... Read More

Initialize HashSet in Java

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 15:00:21

14K+ Views

A set is a collection which does not allows duplicate values. HashSet is an implementation of a Set. Following are the ways in which we can initialize a HashSet in Java.Using constructor − Pass a collection to Constructor to initialize an HashSet.Using addAll() − Pass a collection to Collections.addAll() to ... Read More

How to prevent object of a class from garbage collection in Java?

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 14:30:45

209 Views

If a object is no more referenced by a live reference then it becomes eligible for garbage collection. See the example below −Examplepublic class Tester{    public static void main(String[] args) {       test();    }    public static void test(){       A a = ... Read More

How do you access jagged arrays in C#?

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 14:26:01

93 Views

A Jagged array is an array of arrays. You can declare a jagged array named scores of type int as.int [][] points;Let us now see how to initialize it.int[][] points = new int[][]{new int[]{10, 5}, new int[]{30, 40}, new int[]{70, 80}, new int[]{ 60, 70 }};Access the jagged array element ... Read More

How to use the Sort() method of array class in C#?

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 14:16:54

163 Views

The Sort() method sorts the elements in an entire one-dimensional Array using the IComparable implementation of each element of the Array.Set the array.int[] list = { 22, 12, 65, 9};Use the Sort() method to sort the array.Array.Sort(list);The following is an example to learn how to work with the Sort() method.Example Live ... Read More

What is the copy-and-swap idiom in C++?

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 13:51:21

190 Views

The assignment consists of 2 steps, tearing an object's old state and building a new state for it. The destructor is used for the first step and a copy constructor does the second step. Implementing both of these is straightforward. But when overloading the assignment operator, it can become quite ... Read More

How to use the GetValue() method of array class in C#?

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 12:42:50

3K+ Views

The GetValue() method of array class in C# gets the value at the specified position in the one-dimensional Array. The index is specified as a 32-bit integer.We have set the array values first using the Array.CreateInstance method.Array arr = Array.CreateInstance(typeof(String), 3, 6); arr.SetValue("One", 0, 0); arr.SetValue("Two", 0, 1); arr.SetValue("Three", 0, ... Read More

How to use StringBuilder in C#?

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 12:39:48

254 Views

With StringBuilder, you can expand the number of characters in the string. String cannot be changed once it is created, but StringBuildercan be expanded. It does not create a new object in the memory.Initialize StringBuilder.StringBuilder str = new StringBuilder();Let us see an example to learn how to work with StringBuilder ... Read More

Advertisements