DEV Community

Cover image for One Commit at a Time ! Series - 12
Annapoorani Kadhiravan
Annapoorani Kadhiravan

Posted on

One Commit at a Time ! Series - 12

JAVA

Copying 2d Arrays Using Loop
Similar to the single-dimensional array, we can also copy the 2-dimensional array using the for loop. For example,

import java.util.Arrays;

class Main {
    public static void main(String[] args) {

        int[][] source = {
              {1, 2, 3, 4}, 
              {5, 6},
              {0, 2, 42, -4, 5}
              };

        int[][] destination = new int[source.length][];

        for (int i = 0; i < destination.length; ++i) {

            // allocating space for each row of destination array
            destination[i] = new int[source[i].length];

            for (int j = 0; j < destination[i].length; ++j) {
                destination[i][j] = source[i][j];
            }
        }

        // displaying destination array
        System.out.println(Arrays.deepToString(destination));  

    }
}
Enter fullscreen mode Exit fullscreen mode

Output:

[[1, 2, 3, 4], [5, 6], [0, 2, 42, -4, 5]]

In the above program,

System.out.println(Arrays.deepToString(destination);
Here, the deepToString() method is used to provide a better representation of the 2-dimensional array.


SQL

BETWEEN Operator
The BETWEEN operator is used in the WHERE clause to select values within a specified range.

The range is inclusive - the beginning and end values of the range are included in the results.

The values can be numbers, text, or dates.

ExampleGet your own SQL Server
Select all products with a price between 10 and 20:

SELECT * FROM Products
WHERE Price BETWEEN 10 AND 20;
Enter fullscreen mode Exit fullscreen mode

Syntax
SELECT column_name(s)
FROM table_name
WHERE column_name BETWEEN value1 AND value2;


Reference :
https://www.programiz.com/java-programming/copy-arrays
https://www.w3schools.com/sql/sql_between.asp

Top comments (0)