Ankith Reddy has Published 1132 Articles

Insert all elements of other Collection to Specified Index of Java ArrayList

Ankith Reddy

Ankith Reddy

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

248 Views

The elements of a Collection can be inserted at the specified index of the ArrayList using the method java.util.ArrayList.addAll(). This method has two parameters i.e. the specific index at which to start inserting the Collection elements in the ArrayList and the Collection itself.If there is an element already present at ... Read More

Get the last index of a particular element in an ArrayList in Java

Ankith Reddy

Ankith Reddy

Updated on 29-Jun-2020 13:40:46

627 Views

The last index of a particular element in an ArrayList can be obtained by using the method java.util.ArrayList.lastIndexOf(). This method returns the index of the last occurance of the element that is specified. If the element is not available in the ArrayList, then this method returns -1.A program that demonstrates ... Read More

Remove the last entry of the TreeMap in Java

Ankith Reddy

Ankith Reddy

Updated on 29-Jun-2020 13:38:04

533 Views

To remove the last entry of the TreeMap, use the pollLastEntry() method.Let us first create a TreeMap and add elementsTreeMap m = new TreeMap(); m.put(1, "India"); m.put(2, "US"); m.put(3, "Australia"); m.put(4, "Netherlands"); m.put(5, "Canada");Remove the last entry nowm.pollLastEntry()The following is an example to remove the last entry of the TreeMapExample Live ... Read More

Loop through ArrayList in Java

Ankith Reddy

Ankith Reddy

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

647 Views

The elements of the ArrayList can be accessed one by one by using a for loop. A program that demonstrates this is given as followsExample Live Demoimport java.util.ArrayList; import java.util.List; public class Demo {    public static void main(String[] args) {       ArrayList aList = new ArrayList();     ... Read More

Remove all elements in Java IdentityHashMap

Ankith Reddy

Ankith Reddy

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

71 Views

Use the clear() method to remove all the elements from IdentityHashMap in Java.Create a IdentityHashMap and add some elementsMap 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 us remove all the elementm.clear();The following is ... Read More

NavigableMap lowerEntry() method in Java

Ankith Reddy

Ankith Reddy

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

58 Views

The lowerEntry() method in NavigabelMap returns a key-value mapping associated with the greatest key strictly less than the given key.The following is an example to implement lowerEntry() methodExample Live Demoimport java.util.*; public class Demo {    public static void main(String[] args) {       NavigableMap n = new TreeMap();   ... Read More

List MySQL tables and sizes ordered by size?

Ankith Reddy

Ankith Reddy

Updated on 29-Jun-2020 12:17:27

1K+ Views

You can do this with the help of information_schema.tables. The syntax is as follows -SELECT TABLE_NAME, table_rows, data_length, index_length, round(((data_length + index_length) / 1024 / 1024), 2) "MB Size" FROM information_schema.TABLES WHERE table_schema = "yourDatabaseName" ORDER BY (data_length + index_length) ASC;To understand the above syntax, let us implement it for ... Read More

How to get volley elements in array list in android?

Ankith Reddy

Ankith Reddy

Updated on 29-Jun-2020 12:04:45

565 Views

This example demonstrate about How to get volley elements in array list 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. In ... Read More

How to read volley json array in android?

Ankith Reddy

Ankith Reddy

Updated on 29-Jun-2020 11:58:05

1K+ Views

This example demonstrate about How to read volley json array 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.     In the ... Read More

How to sort volley elements in android?

Ankith Reddy

Ankith Reddy

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

94 Views

This example demonstrate about How to sort volley elements 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.     In the above ... Read More

Previous 1 ... 4 5 6 7 8 ... 114 Next
Advertisements