Samual Sam has Published 2492 Articles

Passing a vector to constructor in C++

Samual Sam

Samual Sam

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

1K+ Views

This is a simple C++ program to pass a vector to a constructor.AlgorithmBegin    Declare a class named as vector.       Declare vec of vector type.       Declare a constructor of vector class.          Pass a vector object v as a parameter to ... Read More

Java Program to insert all elements of other Collection to specified Index of ArrayList

Samual Sam

Samual Sam

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

68 Views

Let us first create an ArraList and add some elements to it −ArrayList < String > arr = new ArrayList < String > (); arr.add("50"); arr.add("100"); arr.add("150"); arr.add("200"); arr.add("250"); arr.add("300");Now, create a new collection. We are creating Vector here −Vectorvector = new Vector(); vector.add("500"); vector.add("700"); vector.add("800"); vector.add("1000");Now, we will append ... Read More

CharBuffer compact() method in Java

Samual Sam

Samual Sam

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

67 Views

The buffer can be compacted using the compact() method in the class java.nio.CharBuffer. This method does not require a parameter and it returns the new compacted CharBuffer with the same content as the original buffer. If the buffer is read-only, then the ReadOnlyBufferException is thrown.A program that demonstrates this is ... Read More

LinkedTransferQueue in Java

Samual Sam

Samual Sam

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

39 Views

The LinkedTransferQueue Class in Java has a transfer queue that has unbounded functionality and is based on linked nodes. It uses FIFO for ordering elements. This class implements the Collection interface as well as the AbstractQueue class. It is a part of the Java Collection Framework.A program that demonstrates this ... Read More

How to specify the encoding type used by forms that post data back to the Web application in a JSP?

Samual Sam

Samual Sam

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

251 Views

The tag is used to specify the encoding type used by forms that post data back to the Web application.AttributeThe tag has the following attributes −AttributeDescriptionRequiredDefaultkeyName of character encoding you want to apply when decoding request parameters.YesNoneYou use the tag when you want to specify the character ... Read More

How to retain elements from a Collection in another Collection

Samual Sam

Samual Sam

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

76 Views

Let’s say the following is our Collection i.e. ArrayList −Listlist = new ArrayList(); list.add(100); list.add(200); list.add(200); list.add(200); list.add(300); list.add(400); list.add(400); list.add(500);Now, create another Collection −List list2 = new ArrayList(); list2.add(100); list2.add(200); list2.add(300); list2.add(400);To retain all elements from a Collection in another Collection, try the following with list and list2 ... Read More

Convert PHP variable “11:00 AM” to MySQL time format?

Samual Sam

Samual Sam

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

248 Views

Use DateTime to convert PHP variable “11:00 AM: to MySQL time format.The PHP code is as follows −$phpTime = '11:00 AM'; echo('The PHP Time Format is ='); echo ($phpTime); $timeFormat = DateTime::createFromFormat( 'H:i A', $phpTime); $MySQLTimeFormat = $timeFormat->format( 'H:i:s'); echo (' '); echo('The MySQL Time Format is ='); echo ($MySQLTimeFormat);The ... Read More

How to test if a List is an Unmodifable List in Java?

Samual Sam

Samual Sam

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

858 Views

We will first set a list to unmodifiable and after that test if it is unmodifiable or not. Let us create a List and add elements −List list = new LinkedList (); list.add(10); list.add(20); list.add(30); list.add(40); list.add(50);Set the above list to unmodifiable −Listunmodifiable = Collections.unmodifiableList(list);Now, use If-else, to ... Read More

ConcurrentLinkedDeque in Java

Samual Sam

Samual Sam

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

44 Views

The ConcurrentLinkedDeque Class in Java implements a deque and used a concurrent linked list for help. 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

CharBuffer allocate() method in Java

Samual Sam

Samual Sam

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

96 Views

A new CharBuffer can be allocated using the method allocate() in the class java.nio.CharBuffer. This method requires a single parameter i.e. the capacity of the buffer. It returns the new CharBuffer that is allocated. If the capacity provided is negative, then the IllegalArgumentException is thrown.A program that demonstrates this is ... Read More

Advertisements