Samual Sam has Published 2310 Articles

LocalTime minusSeconds() method in Java

Samual Sam

Samual Sam

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

82 Views

An immutable copy of a LocalTime object where some seconds are subtracted from it can be obtained using the minusSeconds() method in the LocalTime class in Java. This method requires a single parameter i.e. the number of seconds to be subtracted and it returns the LocalTime object with the subtracted ... Read More

Simple way to find if two different lists contain exactly the same elements in Java

Samual Sam

Samual Sam

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

2K+ Views

Two lists are equal if they consist of same number of elements in the same order.Let’s say we have the following two lists −ListarrList1 = Arrays.asList(new Integer[] { 10, 20, 30, 45, 55, 70, 90, 100 }); ListarrList2 = Arrays.asList(new Integer[] {15, 25, 35, 50, 55, 75, 95, 120});Now, let’s ... Read More

Delete last 4 letters in MySQL?

Samual Sam

Samual Sam

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

139 Views

You can use SUBSTRING() along with UPDATE command to delete last 4 letters. Let us first create a table −mysql> create table DemoTable (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    StudentSubject varchar(100) ); Query OK, 0 rows affected (0.57 sec)Insert some records in the table using insert ... Read More

MySQL command-line tool: How to find out number of rows affected by a DELETE?

Samual Sam

Samual Sam

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

708 Views

You can use row_count() at the end for this. Let us first create a table −mysql> create table rowAfftectedByDeleteDemo    -> (    -> CustomerId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> CustomerName varchar(20)    -> ); Query OK, 0 rows affected (0.86 sec)Insert some records in the table ... Read More

LocalDateTime withNano() method in Java

Samual Sam

Samual Sam

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

292 Views

An immutable copy of a LocalDateTime with the nanoseconds altered as required is done using the method withNano() in the LocalDateTime class in Java. This method requires a single parameter i.e. the nanosecond that is to be set in the LocalDateTime and it returns the LocalDateTime with the nanosecond altered ... Read More

Create a temporary file in Java

Samual Sam

Samual Sam

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

7K+ Views

A temporary file can be created using the method java.io.File.createTempFile(). This method requires two parameters i.e. the prefix to define the file name and the suffix to define the file extension. It also returns the abstract path name for the temporary file created.A program that demonstrates this is given as ... Read More

CharBuffer array() method in Java

Samual Sam

Samual Sam

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

150 Views

A char array for the buffer can be obtained using the method array() in the class java.nio.CharBuffer. 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

LocalDateTime getYear() method in Java

Samual Sam

Samual Sam

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

642 Views

The year for a particular LocalDateTime can be obtained using the getYear() method in the LocalDateTime class in Java. This method requires no parameters and it returns the year which can range from MIN_YEAR to MAX_YEAR.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo ... Read More

How to create a Queue from LinkedList in Java?

Samual Sam

Samual Sam

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

394 Views

Let us create a queue from LinkedList like this −Queuequeue = new LinkedList(); queue.add("P"); queue.add("Q"); queue.add("R"); queue.add("S"); queue.add("T"); queue.add("U"); queue.add("V");Now, use a List to display the elements of the queue −Listlist = new ArrayList(queue);Example Live Demoimport java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.Queue; public class Demo {    public static void ... Read More

How to export specific column data in MySQL?

Samual Sam

Samual Sam

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

921 Views

To export specific column data in MySQL, use OUTFILE −select yourColumnName from yourTableName into outfile 'yourLocationOfFile’;Let us first create a table −mysql> create table DemoTable (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    StudentFirstName varchar(20),    StudentLastName varchar(20) ); Query OK, 0 rows affected (0.54 sec)Insert records in ... Read More

Advertisements