Samual Sam has Published 2492 Articles

JavaTuples addAtX() method for Septet class

Samual Sam

Samual Sam

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

60 Views

The addAtX() method is used to add value to the Septet Tuple. The index can be set here with the X i.e. the place where the value gets added.Let us first see what we need to work with JavaTuples. To work with Septet class in JavaTuples, you need to import ... Read More

Java Program to check if a Float is Infinite or Not a Number(NAN)

Samual Sam

Samual Sam

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

2K+ Views

To check if a Float is isInfinite, use the isInfinite() method and to check for NAN, use the isNaN() method.Example Live Demopublic class Demo {    public static void main(String[] args) {       float value1 = (float) 1 / 0;       boolean res1 = Float.isInfinite(value1);     ... Read More

How to set time data type to be only HH:MM in MySQL?

Samual Sam

Samual Sam

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

3K+ Views

You can use DATE_FORMAT() to set time data type to be only HH:MM. Following is the syntax −select DATE_FORMAT(yourColumnName, "%H:%i") AS anyAliasName from yourTableName;Let us first create a table −mysql> create table DemoTable (    Arrivaltime time ); Query OK, 0 rows affected (0.61 sec)Insert records in the table using insert ... Read More

What are JSP literals?

Samual Sam

Samual Sam

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

545 Views

The JSP expression language defines the following literals −Boolean − true and falseInteger − as in JavaFloating point − as in JavaString − with single and double quotes; " is escaped as \", ' is escaped as \', and \ is escaped as \.Null − null

ByteBuffer allocateDirect() method in Java

Samual Sam

Samual Sam

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

244 Views

A direct byte buffer can be allocated using the method allocateDirect() in the class java.nio.ByteBuffer. This method requires a single parameter i.e. the capacity in bytes and it returns the direct byte buffer. If the capacity provided is negative, then the IllegalArgumentException is thrown.A program that demonstrates this is given ... Read More

Exception handling and object destruction in C++

Samual Sam

Samual Sam

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

648 Views

Destructors in C++ basically called when objects will get destroyed and release memory from the system. When an exception is thrown in the class, the destructor is called automatically before the catch block gets executed.AlgorithmBegin    Declare a class sample1.       Declare a constructor of sample1.     ... Read More

How to display random numbers less than 20 in Java

Samual Sam

Samual Sam

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

246 Views

At first, create a Random class object −Random rand = new Random();Now, create a new array −int num; int arr[] = new int[10];Loop through and set the Random nextInt with 20 as parameter since you want random numbers less than 20 −for (int j = 0; j

How to convert string to bitset in MySQL?

Samual Sam

Samual Sam

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

196 Views

To convert string to bitset, use the CONV() method. Let us first create a table −mysql> create table DemoTable (    stringValue BIT(4) ); Query OK, 0 rows affected (3.50 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(CONV('1110', 2, 10) * 1); Query OK, ... Read More

Binary search in sorted vector of pairs in C++

Samual Sam

Samual Sam

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

402 Views

This is a C++ program to implement Binary search in a sorted vector of pairs.AlgorithmBegin    Declare a structure keycompare.       Function operator()(const pair& v, const int& k)       returns Booleans.          Status = v.first < k.          Return status. ... Read More

ByteBuffer array() method in Java

Samual Sam

Samual Sam

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

448 Views

A byte array for the buffer can be obtained using the method array() in the class java.nio.ByteBuffer. If the returned array is modified, then the contents of the buffer are also similarly modified and vice versa. If the buffer is read-only, then the ReadOnlyBufferException is thrown.A program that demonstrates this ... Read More

Advertisements