Samual Sam has Published 2492 Articles

How to create a read-only list in Java?

Samual Sam

Samual Sam

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

202 Views

Let us first create a List in Java −Listlist = new ArrayList(); list.add("A"); list.add("B"); list.add("C");Now to convert the above list to read-only, use Collections −list = Collections.unmodifiableList(list);We have converted the above list to read-only. Now, if you will try to add more elements to the list, then the following error ... Read More

Serial Line Internet Protocol (SLIP)

Samual Sam

Samual Sam

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

6K+ Views

Serial Line Internet Protocol (SLIP) is a simple protocol that works with TCP/IP for communication over serial ports and routers. They provide communications between machines that were previously configured for direct communication with each other.For example, a client may be connected to the Internet service provider (ISP) with a slower ... Read More

Difference between Synchronized ArrayList and CopyOnWriteArrayList in Java

Samual Sam

Samual Sam

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

899 Views

Synchronized ArrayList and CopyOnWriteArrayList are useful for synchronizing the ArrayList. This is necessary for a multi-threaded environment to make sure thread safety is achieved.The differences between Synchronized ArrayList and CopyOnWriteArrayList are given as follows −Synchronized ArrayListCopyOnWriteArrayListSynchronized ArrayList is used to synchronize the ArrayList.CopyOnWriteArrayList is used to synchronize the ArrayList.The Java ... Read More

How to fetch elements with iterator in Java?

Samual Sam

Samual Sam

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

257 Views

Let us first create a List and add elements −Listlist = Arrays.asList(new String[] { "P", "Q", "R", "S", "T", "U", "V", "W" });Now, use Iterator to fetch each element −Iteratori = list.iterator();Display the elements −while (i.hasNext()) {    System.out.println(i.next()); }Example Live Demoimport java.util.Arrays; import java.util.Iterator; import java.util.List; public class Demo { ... Read More

Can't find my.ini in MySQL directory?

Samual Sam

Samual Sam

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

6K+ Views

The my.ini is in hidden folder of program data. First go to C: drive and then hidden folder of program data. From that, move to the MySQL version directory.Here is the snapshot of the C: drive −Click on C drive. The snapshot is as follows. Here, you can see the ... Read More

How to shuffle a std::vector in C++

Samual Sam

Samual Sam

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

1K+ Views

A vector shuffle can be done in the Fisher-Yates shuffle algorithm.In this algorithm, a linear scan of a vector is done and then swap each element with a random element among all the remaining element, including the element itself.AlgorithmBegin   Declare a function show().       Pass a constructor ... Read More

What are JSTL Core tags in JSP?

Samual Sam

Samual Sam

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

240 Views

The core group of tags is the most commonly used JSTL tags. Following is the syntax to include the JSTL Core library in your JSP −Following table lists out the core JSTL Tags −S.No.Tag & Description1Like , but for expressions.2Sets the result of an expression evaluation in a 'scope'3Removes a ... Read More

How to find ArrayBlockingQueueis empty or not in android?

Samual Sam

Samual Sam

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

26 Views

Before getting into example, we should know what arrayblockingqueue is, it travels FIFO manner and first element going to live longest period of time and last element of the queue going to live short period of the time.This example demonstrate about How to find ArrayBlockingQueue is empty or not in ... Read More

Java Program to display sub-list of ArrayList

Samual Sam

Samual Sam

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

58 Views

To display the sub-list of ArrayList, let us first declare an ArrayList and add some elements −ArrayListarrayList = new ArrayList(); arrayList.add("100"); arrayList.add("200"); arrayList.add("300"); arrayList.add("400"); arrayList.add("500"); arrayList.add("600"); arrayList.add("700"); arrayList.add("800"); arrayList.add("900"); arrayList.add("1000");Get the sub-list of ArrayList now. Here, we are getting sub-list from array index 4 to 8 −Listlist = arrayList.subList(4, 8);Example Live ... Read More

ConcurrentLinkedQueue in Java

Samual Sam

Samual Sam

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

97 Views

The ConcurrentLinkedQueue class in Java is used to implement a queue using a concurrent linked list. This class implements the Collection interface as well as the AbstractCollection class. It is a part of the Java Collection Framework.A program that demonstrates this is given as follows −Example Live Demoimport java.util.concurrent.*; public class ... Read More

Advertisements