Karthikeya Boyini has Published 2193 Articles

Append all elements of other Collection to ArrayList in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

478 Views

The elements of a Collection can be appended at the end of the ArrayList using the method java.util.ArrayList.addAll(). This method takes a single parameter i.e. the Collection whose elements are added to the ArrayList.A program that demonstrates this is given as follows −Example Live Demoimport java.util.ArrayList; import java.util.Vector; public class Demo ... Read More

Retrieve the last element from a LinkedList in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

2K+ Views

The last element of a Linked List can be retrieved using the method java.util.LinkedList.getLast() respectively. This method does not require any parameters and it returns the last element of the LinkedList.A program that demonstrates this is given as follows −Example Live Demoimport java.util.LinkedList; public class Demo {    public static void ... Read More

Java Program to get the File object with the absolute path for the directory or file

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

1K+ Views

The method java.io.File.getAbsoluteFile() is used to get the File object with the absolute path for the directory or file. This method requires no parameters.A program that demonstrates this is given as follows −Example Live Demoimport java.io.File; public class Demo {    public static void main(String[] args) {       File ... Read More

IdentityHashMap size() method in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

95 Views

The size() method is used in IdentityHashMap to get the size of the map i.e. the count of elements.Let us first create IdentityHashMap and add some elements −Map m = new IdentityHashMap(); m.put("1", 100); m.put("2", 200); m.put("3", 300); m.put("4", 150); m.put("5", 110); m.put("6", 50);Now, get the size −m.size()The following is ... Read More

Retrieve TreeMap size in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

204 Views

Get the TreeMap size using the size() method.First, create a TreeMap and add elements to it −TreeMap m = new TreeMap(); m.put(1, "PHP"); m.put(2, "jQuery"); m.put(3, "JavaScript"); m.put(4, "Ruby"); m.put(5, "Java"); m.put(6, "AngularJS"); m.put(7, "ExpressJS");Count the number of elements in the above TreeMap or get the size using the size() ... Read More

Remove a range of elements from a LinkedList in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

407 Views

A range of elements can be removed from a LinkedList by using the method java.util.LinkedList.clear() along with the method java.util.LinkedList.subList(). A program that demonstrates this is given as follows −Example Live Demoimport java.util.LinkedList; public class Demo { public static void main(String[] args) { ... Read More

Bandwidth Delay Product

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

10K+ Views

Bandwidth delay product is a measurement of how many bits can fill up a network link. It gives the maximum amount of data that can be transmitted by the sender at a given time before waiting for acknowledgment. Thus it is the maximum amount of unacknowledged data.MeasurementBandwidth delay product is ... Read More

Create a new empty file in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

14K+ Views

A new empty file with the required abstract path name can be created using the method java.io.File.createNewFile(). This method requires no parameters and it returns true if the file is newly created and it did not exist previously. If the file existed previously, it returns false.A program that demonstrates this ... Read More

Get the value associated with a given key in Java HashMap

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

2K+ Views

Use the get() method to get the value associated with a given key.Here is our HashMap and its elements −// Create a hash map HashMap hm = new HashMap(); // Put elements to the map hm.put("Bag", new Integer(1100)); hm.put("Sunglasses", new Integer(2000)); hm.put("Frames", new Integer(800)); hm.put("Wallet", new Integer(700)); hm.put("Belt", new Integer(600));To ... Read More

Go-Back-N ARQ

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

13K+ Views

Go-Back-N Automatic Repeat reQuest (Go-Back-N ARQ), is a data link layer protocol that uses a sliding window method for reliable and sequential delivery of data frames. It is a case of sliding window protocol having to send window size of N and receiving window size of 1.Working PrincipleGo – Back ... Read More

Advertisements