Samual Sam has Published 2492 Articles

What is a Quartet class in JavaTuples?

Samual Sam

Samual Sam

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

75 Views

A Quartet class is a Tuple of four elements. It is part of the JavaTuples library.The following is the declaration −public final class Quartet extends Tuple implements IValue0, IValue0, IValue0, IValue0Let us first see what we need to work with JavaTuples. To work with Quartet class in JavaTuples, you need ... Read More

Instant toString() method in Java

Samual Sam

Samual Sam

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

166 Views

The range of values for a field can be obtained using the range() method in the Instant class in Java. This method requires a single parameter i.e. the ChronoField for which the range of values are required and it returns the range of valid values for the ChronoField.A program that ... Read More

Java Program to evaluate mathematical expressions in String

Samual Sam

Samual Sam

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

3K+ Views

To evaluate mathematical expression in String, use Nashorn JavaScript in Java i.e. scripting. Nashorn invoke dynamics feature, introduced in Java 7 to improve performance.For scripting, use the ScriptEngineManager class for the engine −ScriptEngineManager scriptEngineManager = new ScriptEngineManager(); ScriptEngine scriptEngine = scriptEngineManager.getEngineByName("JavaScript");Now for JavaScript code from string, use eval i.e. execute ... Read More

MySQL query to get a substring from a string except the last three characters?

Samual Sam

Samual Sam

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

609 Views

For this, you can use SUBSTR along with length().Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    FirstName varchar(20)    ); Query OK, 0 rows affected (1.31 sec)Following is the query to insert some records in the table ... Read More

Duration minusMillis() method in Java

Samual Sam

Samual Sam

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

63 Views

An immutable copy of a duration where some milliseconds are removed from it can be obtained using the minusMillis() method in the Duration class in Java. This method requires a single parameter i.e. the number of milliseconds to be subtracted and it returns the duration with the subtracted milliseconds.A program ... Read More

MySQL where column = 'x, y, z'?

Samual Sam

Samual Sam

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

198 Views

You can use IN operator for this.The syntax is as follows −SELECT *FROM yourTableName WHERE yourColumnName IN(‘yourValue1’, ‘yourValue2’, ‘yourValue3’, ...........N);To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table InOperatorDemo    -> (    -> ClientId int   ... Read More

How can I save new Date() in MongoDB?

Samual Sam

Samual Sam

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

108 Views

To save new Date() in MongoDB, you can use new ISODate(). Let us create a collection with documents −> db.saveDateDemo.insertOne({"UserName":"John", "UserLoginDatetime":new ISODate('2018-01-31 12:34:56')}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cbd67d4de8cc557214c0e04") } > db.saveDateDemo.insertOne({"UserName":"John", "UserLoginDatetime":new ISODate('2019-02-01 04:01:10')}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cbd67e8de8cc557214c0e05") } > db.saveDateDemo.insertOne({"UserName":"John", ... Read More

Create Quartet Tuple in Java using with() method

Samual Sam

Samual Sam

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

64 Views

The with() method is also used to create a Quartet tuple in Java.Let us first see what we need to work with JavaTuples. To work with Quartet class in JavaTuples, you need to import the following package −import org.javatuples.Quartet;Note − Steps to download and run JavaTuples program If you are ... Read More

Instant get() method in Java

Samual Sam

Samual Sam

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

177 Views

The value of the required ChronoField for an Instant can be obtained using the get() method in the Instant class in Java. This method requires a single parameter i.e. the ChronoField and it returns the value of the ChronoField that was passed as a parameter.A program that demonstrates this is ... Read More

Java Program to create a Calculator

Samual Sam

Samual Sam

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

1K+ Views

To create a calculator with Java Swings, try the following code −Exampleimport java.awt.Color; import java.awt.Container; import java.awt.FlowLayout; import javax.swing.JFrame; import javax.swing.JLabel; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JTextField; public class SwingDemo extends JFrame implements ActionListener {    JButton one, two, three, four, five, six, seven, eight, nine, num0, ... Read More

Advertisements