DEV Community

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

Posted on

One Commit at a Time ! Series - 23

JAVA

public class Main {
  public static void main(String[] args) {
    int x = 5;
    ++x;
    System.out.println(x);
  }
}
Enter fullscreen mode Exit fullscreen mode

Explanation :

This Java program demonstrates the use of the increment operator (++) to increase the value of a variable.

Here is a step-by-step breakdown:

  1. int x = 5;
  2. Declares an integer variable named x and initializes it with the value 5.

  3. ++x;

  4. Applies the pre-increment operator to x. This adds 1 directly to the current value of x.

  5. Since x was 5, it now becomes 6. (Because it is placed before the variable, it increments the value immediately before using it).

  6. System.out.println(x);

  7. Prints the current value of x (6) to the console.

Output

6

Enter fullscreen mode Exit fullscreen mode

SQL

SQL SELECT DISTINCT Statement
The SELECT DISTINCT statement is used to return only distinct (unique) values.

In a table, a column may contain several duplicate values - and sometimes you want to list only the unique values.

Example
Select all the distinct (unique) countries from the "Customers" table:

SELECT DISTINCT Country FROM Customers;

Enter fullscreen mode Exit fullscreen mode

SELECT DISTINCT Syntax

SELECT DISTINCT column1, column2, ...
FROM table_name;


References :

https://www.w3schools.com/sql/sql_distinct.asp
https://www.w3schools.com/java/java_examples.asp

Top comments (0)