Samual Sam has Published 2310 Articles

Java Program to fill an array with random numbers

Samual Sam

Samual Sam

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

3K+ Views

Let us first crate an array −double[] arr = new double[5];Now, create Random class object −Random randNum = new Random();Now, fill the above array with random numbers −for (int i = 0; i < 5; i++) { arr[i] = randNum.nextInt(); }Example Live Demoimport java.util.Arrays; import java.util.Random; public class Demo {   ... Read More

LocalDateTime plusMonths() method in Java

Samual Sam

Samual Sam

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

135 Views

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

DoubleBuffer hasArray() method in Java

Samual Sam

Samual Sam

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

111 Views

It can be checked if a buffer has the backing of an accessible double array by using the method hasArray() in the class java.nio.DoubleBuffer. This method returns true if the buffer has the backing of an accessible double array and false otherwise.A program that demonstrates this is given as follows ... Read More

LocalDateTime plusDays() method in Java

Samual Sam

Samual Sam

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

307 Views

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

LocalDateTime range() method in Java

Samual Sam

Samual Sam

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

182 Views

The range of values for a ChronoField can be obtained using the range() method in the LocalDateTime class in Java. This method requires a single parameter i.e. the ChronoField for which the range of values is required and it returns the range of values.A program that demonstrates this is given ... Read More

Ordering alphabetically in MySQL except for one entry?

Samual Sam

Samual Sam

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

152 Views

You can use ORDER BY clause for this. Let us first create a table −mysql> create table DemoTable (    FirstName varchar(200) ); Query OK, 0 rows affected (0.93 sec)Insert records in the table using insert command −mysql> insert into DemoTable values('Larry'); Query OK, 1 row affected (0.17 sec) mysql> ... Read More

DoubleBuffer duplicate() method in Java

Samual Sam

Samual Sam

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

116 Views

A duplicate buffer of a buffer can be created using the method duplicate() in the class java.nio.DoubleBuffer. This duplicate buffer is identical to the original buffer. The method duplicate() returns the duplicate buffer that was created.A program that demonstrates this is given as follows −Example Live Demoimport java.nio.*; import java.util.*; public ... Read More

LocalDateTime now() Method in Java

Samual Sam

Samual Sam

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

2K+ Views

The current date-time can be obtained from the system clock in the default time zone using the now() method in the LocalDateTime class in Java. This method requires no parameters and it returns the current date-time from the system clock in the default time zoneA program that demonstrates this is ... Read More

How to select data from a table where the table name has blank spaces in MYSQL?

Samual Sam

Samual Sam

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

1K+ Views

You need to use backticks around the table name where the table name has blank space. Let us first create a table. Here, we have used backtick −mysql> create table `Demo Table138` (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Price int ); Query OK, 0 rows affected (0.47 ... Read More

DoubleBuffer compact() method in Java

Samual Sam

Samual Sam

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

142 Views

The buffer can be compacted using the compact() method in the class java.nio.DoubleBuffer. This method does not require a parameter and it returns the new compacted DoubleBuffer 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

Advertisements