Found 33676 Articles for Programming

Set key in the JavaTuples KeyValue class

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

120 Views

To set key in the JavaTuples KeyValue class, you need to use the setKey() method. Let us first see what we need to work with JavaTuples. To work with KeyValue class in JavaTuples, you need to import the following package:import org.javatuples.KeyValue;Note: Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project → Properties → Java Build Path → Add External Jars and upload the downloaded JavaTuples jar file. Refer the below guide for all the steps to run JavaTuples:Steps: How to run JavaTuples program in EclipseThe following is an example to set ... Read More

Sorting a vector in C++

Nishu Kumari
Updated on 30-Jan-2025 14:46:25

19K+ Views

Sorting a vector in C++ means arranging its elements in a specific order, like ascending or descending. This is a common task when you need to organize data efficiently. C++ provides different ways to sort a vector. In this article, we will look at different ways to sort a vector in C++. Let's look at this example to better understand it: For the vector: V = {5, 3, 8, 1, 2} Sorted Output: {1, 2, 3, 5, 8} For the vector: V = {22, 23, 5, 6, 34} Sorted Output: {5, 6, 22, 23, 34} Approaches to ... Read More

Passing a vector to constructor in C++

Revathi Satya Kondra
Updated on 26-May-2025 17:24:41

1K+ Views

In C++, you can pass a std::vector to a class constructor to create a list of values when the object is created. So that the object can store or work with a list of values right from the beginning. Why do You Pass a Vector to a Constructor? Passing a Vector to a Constructor allows the object to be initialized with data at the time of creation. When you pass a vector to a function, it simplifies the code by eliminating the need to initialize the function parameters, as the vector ... Read More

Fetch the key from a KeyValue Tuple in Java

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

166 Views

To fetch the key from a KeyValue tuple in Java, use the getKey() method. Let us first see what we need to work with JavaTuples. To work with KeyValue class in JavaTuples, you need to import the following package:import org.javatuples.KeyValue;Note: Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project → Properties → Java Build Path → Add External Jars and upload the downloaded JavaTuples jar file. Refer the below guide for all the steps to run JavaTuples:Steps: How to run JavaTuples program in EclipseThe following is an example to fetch the ... Read More

How to sum up elements of a C++ vector?

Vishesh Raina
Updated on 01-Aug-2024 12:27:52

27K+ Views

In this article, we will understand how to sum the elements present inside a vector in C++. A vector is a dynamically allocated array with variable size. The sum of elements of a vector can be calculated in a number of ways, and we will discuss two such ways. Problem Statement Given a non-empty vector of integers, calculate the sum of all elements of the vector using multiple approaches in C++. Examples The following examples give the input and output of some test cases : Input vector vec={1, 3, 4, 5, 2, 3} Output ... Read More

How to find the current row of a ResultSet object using JDBC?

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

720 Views

The getRow() method of the ResultSet class returns the row number at which the ResultSet pointer exists in the current instance.Assume we have a table named cricketers_data with 6 records as shown below:+------------+------------+---------------+----------------+-------------+ | First_Name | Last_Name  | Date_Of_Birth | Place_Of_Birth | Country     | +------------+------------+---------------+----------------+-------------+ | Shikhar    | Dhawan     | 1981-12-05    | Delhi          | India       | | Jonathan   | Trott      | 1981-04-22    | CapeTown       | SouthAfrica | | Lumara     | Sangakkara | 1977-10-27    | Matale     ... Read More

How to fetch the value from a KeyValue Tuple in Java?

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

212 Views

To fetch the value from a KeyValue tuple in Java, use the getValue() method. Let us first see what we need to work with JavaTuples. To work with KeyValue class in JavaTuples, you need to import the following package:import org.javatuples.KeyValue;Note: Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project → Properties → Java Build Path → Add External Jars and upload the downloaded JavaTuples jar file. Refer the below guide for all the steps to run JavaTuples:Steps: How to run JavaTuples program in EclipseThe following is an example to fetch the ... Read More

Create KeyValue Tuple from a List collection in Java

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

148 Views

To create KeyValue tuple from List collection, use the fromCollection() method. Let us first see what we need to work with JavaTuples. To work with KeyValue class in JavaTuples, you need to import the following package:import org.javatuples.KeyValue;Note: Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project → Properties → Java Build Path → Add External Jars and upload the downloaded JavaTuples jar file. Refer the below guide for all the steps to run JavaTuples:Steps: How to run JavaTuples program in EclipseThe following is an example to create KeyValue Tuple from List ... Read More

How to append a vector in a vector in C++?

Revathi Satya Kondra
Updated on 02-May-2025 17:56:29

16K+ Views

In C++, a vector is like a array which can be used accordingly. If you want to combine (append) two vectors, you need to add all the elements of one vector to the end of another. This is called appending a vector in a vector. To append a vector in a vector can simply be done by vector insert() method and moreover by using loops and std::move() to transfer elements. There are different ways to append one vector into another in C++. The most common ones are: Using insert() method Using ... Read More

How to move the result set pointer to required position?

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

253 Views

The absolute() method of the ResultSet interface accepts an integer value representing the index of a row and moves the ResultSet pointer of the current ResultSet object to the specified position.Assume we have a table named cricketers_data with 6 records as shown below:+------------+------------+---------------+----------------+-------------+ | First_Name | Last_Name  | Date_Of_Birth | Place_Of_Birth | Country     | +------------+------------+---------------+----------------+-------------+ | Shikhar    | Dhawan     | 1981-12-05    | Delhi          | India       | | Jonathan   | Trott      | 1981-04-22    | CapeTown       | SouthAfrica | | Lumara   ... Read More

Advertisements