Samual Sam has Published 2492 Articles

MySQL query to get sum of each column where every column has same number of values?

Samual Sam

Samual Sam

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

334 Views

You can use aggregate function SUM() for this. Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    FirstValue int,    SecondValue int,    ThirdValue int    ); Query OK, 0 rows affected (0.57 sec)Insert some records in the ... Read More

LocalTime plusNanos() method in Java

Samual Sam

Samual Sam

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

56 Views

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

What is the best way to check capacity in Java?

Samual Sam

Samual Sam

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

1K+ Views

To check capacity in Java, firstly create a list and add elements. After that use ensureCapacity() and increase the capacity.Let us first create an ArrayList and add some elements −ArrayListarrList = new ArrayList(5); arrList.add(100); arrList.add(200); arrList.add(300); arrList.add(400); arrList.add(500);Now, increase the capacity of the ArrayList −arrList.ensureCapacity(15);Meanwhile, with the size() method, you ... Read More

Check if a directory is not empty in Java

Samual Sam

Samual Sam

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

3K+ Views

The method java.io.File.list() is used to obtain the list of the files and directories in the specified directory defined by its path name. This list of files is stored in a string array. If the length of this string array is greater than 0, then the specified directory is not ... Read More

CharBuffer asReadOnlyBuffer() method in Java

Samual Sam

Samual Sam

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

56 Views

A read-only char buffer can be created using the contents of a buffer with the method asReadOnlyBuffer() in the class java.nio.CharBuffer. The new buffer cannot have any modifications as it is a read-only buffer. However, the capacity, positions, limits etc. of the new buffer are the same as the previous ... Read More

LocalTime minusSeconds() method in Java

Samual Sam

Samual Sam

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

50 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

1K+ 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

73 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

466 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

111 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

Advertisements