Karthikeya Boyini has Published 2193 Articles

Add a value to Septet class in JavaTuples

karthikeya Boyini

karthikeya Boyini

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

96 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

LocalDate plusMonths() method in Java

karthikeya Boyini

karthikeya Boyini

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

1K+ Views

An immutable copy of the LocalDate where the months are added to it can be obtained using the plusMonths() method in the LocalDate class in Java. This method requires a single parameter i.e. the number of months to be added and it returns the instant with the added months.A program ... Read More

Java Program to get prime numbers using the Sieve of Eratosthenes algorithm

karthikeya Boyini

karthikeya Boyini

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

395 Views

To find all prime numbers up to any given limit, use the Sieve of Eratosthenes algorithm. At first we have set the value to be checked −int val = 30;Now, we have taken a boolean array with a length one more than the val −boolean[] isprime = new boolean[val + ... Read More

Display IDs in a particular order with MySQL IN()?

karthikeya Boyini

karthikeya Boyini

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

285 Views

To display IDs in a particular order i.e. the order of your choice use FIELD() method.Let us first create a table −mysql> create table DemoTable    (    UserId int    ); Query OK, 0 rows affected (0.64 sec)Following is the query to insert some records in the table using ... Read More

Duration plusNanos() method in Java

karthikeya Boyini

karthikeya Boyini

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

97 Views

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

How to trim commas with MySQL?

karthikeya Boyini

karthikeya Boyini

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

2K+ Views

The syntax is as follows to trim commas −SELECT TRIM(BOTH ', ' FROM yourColumnName) from yourTableName;Let us see an example −mysql> create table TrimCommasDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> AllTechnicalSkills text    -> ); Query OK, 0 rows affected (0.81 sec)Now ... Read More

Perform search/replace for only the first occurrence of a character with session variable in MySQL

karthikeya Boyini

karthikeya Boyini

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

295 Views

To perform search/ replace for only the first occurrence, use the CONCAT and REPLACE() function.The query is as follows to set user defined session variable −mysql> set @Sentence='Thks ks is a my string'; Query OK, 0 rows affected (0.00 sec)In this k will be replaced with i only once. The ... Read More

JavaTuples setAt1() method for Quintet class

karthikeya Boyini

karthikeya Boyini

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

85 Views

The setAt1() method is used to set the Quintet value in JavaTuples and a copy with a new value at the specified index i.e. index 1 here.Let us first see what we need to work with JavaTuples. To work with Quintet class in JavaTuples, you need to import the following ... Read More

LocalDate plusDays() Method in Java

karthikeya Boyini

karthikeya Boyini

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

3K+ Views

An immutable copy of the LocalDate where the days are added to it can be obtained using the plusDays() method in the LocalDate class in Java. This method requires a single parameter i.e. the number of days to be added and it returns the instant with the added days.A program ... Read More

Java Program to calculate the area of a triangle using Heron's Formula

karthikeya Boyini

karthikeya Boyini

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

5K+ Views

Heron’s formula gives the area of a triangle when the length of all three sides are already known.Let’s say we have the following three sides of a triangle −s1 = 15191235.0; s2 = 15191235.0; s3 = 1.01235479;Now, use the Heron’s formulae to find the area −area = (s1+s2+s3)/2.0d; resArea = ... Read More

Advertisements