Arjun Thakur has Published 1109 Articles

Use Iterator to remove an element from a Collection in Java

Arjun Thakur

Arjun Thakur

Updated on 29-Jun-2020 13:54:59

17K+ Views

An element can be removed from a Collection using the Iterator method remove(). This method removes the current element in the Collection. If the remove() method is not preceded by the next() method, then the exception IllegalStateException is thrown.A program that demonstrates this is given as follows.Example Live Demoimport java.util.ArrayList; import ... Read More

Obtain the Previous Index and Next Index in an ArrayList using the ListIterator in Java

Arjun Thakur

Arjun Thakur

Updated on 29-Jun-2020 13:48:53

892 Views

The previous index and next index in an ArrayList can be obtained using the methods previousIndex() and nextIndex() respectively in the ListIterator Interface.The previousIndex() method returns the index of the element that is returned by the previous() method while the nextIndex() method returns the index of the element that is ... Read More

Get the unmodifiable view of the specified ArrayList in Java

Arjun Thakur

Arjun Thakur

Updated on 29-Jun-2020 13:42:25

390 Views

The unmodifiable view of the specified ArrayList can be obtained by using the method java.util.Collections.unmodifiableList(). This method has a single parameter i.e. the ArrayList and it returns the unmodifiable view of that ArrayList.A program that demonstrates this is given as followsExample Live Demoimport java.util.ArrayList; import java.util.ArrayList; import java.util.Collections; import java.util.List; public ... Read More

Check for the existence of a key in Java IdentityHashMap

Arjun Thakur

Arjun Thakur

Updated on 29-Jun-2020 13:20:52

81 Views

Use the containsKey() method to check whether a particular key exists in IdentityHashMap or not.Create a IdentityHashMapMap m = newIdentityHashMap(); m.put("1", 100); m.put("2", 200); m.put("3", 300); m.put("4", 150); m.put("5", 110); m.put("6", 50); m.put("7", 90); m.put("8", 250); m.put("9", 350); m.put("10", 450);Now, let’s say we need to check whether key 7 exists ... Read More

Fetch the value for a specific key in Java IdentityHashMap

Arjun Thakur

Arjun Thakur

Updated on 29-Jun-2020 13:10:08

2K+ Views

To fetch the value for a specific key, use the get() method.As a parameter, set the key you want to fetch and fetch the value.Let’s say you need to fetch value of key 3get("3")The following is an example to fetch the value for a specific key in Java IdentityHashMap −Example Live ... Read More

How to add a NOT NULL column in MySQL?

Arjun Thakur

Arjun Thakur

Updated on 29-Jun-2020 13:01:56

3K+ Views

You can add a not null column at the time of table creation or you can use it for an existing table.Case 1 − Add a not null column at the time of creating a table. The syntax is as followsCREATE TABLE yourTableName (    yourColumnName1 dataType NOT NULL,   ... Read More

How to read json array in reverse order in android?

Arjun Thakur

Arjun Thakur

Updated on 29-Jun-2020 12:02:52

402 Views

This example demonstrate about How to read json array in reverse order in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     ... Read More

Moving left animation with keyframes using CSS3

Arjun Thakur

Arjun Thakur

Updated on 29-Jun-2020 12:01:46

148 Views

You can try to run the following code to move left animation with keyframes using CSS3ExampleLive Demo                    h1 {             -moz-animation-duration: 3s;             -webkit-animation-duration: 3s;           ... Read More

How to sort volley arraylist with custom object in android?

Arjun Thakur

Arjun Thakur

Updated on 29-Jun-2020 11:50:17

91 Views

This example demonstrate about How to sort volley arraylist with custom object in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     ... Read More

UPDATE column to append data into it in MySQL?

Arjun Thakur

Arjun Thakur

Updated on 29-Jun-2020 11:15:14

1K+ Views

To achieve this, the following is the syntax.UPDATE yourTableName set yourColumnName=concat(ifnull(yourColumnName, ””), ’anyValue1, anyValue2, anyValue);To understand the above syntax, let us first create a table. The query to create a table is as follows -mysql> create table AppendDataDemo -> ( -> StudentId int, -> StudentName varchar(100), -> StudentAge int -> ... Read More

Previous 1 ... 5 6 7 8 9 ... 111 Next
Advertisements