DEV Community

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

Posted on

One Commit at a Time ! Series - 24

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 decrement operator (--) to decrease 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-decrement operator to x. This subtracts 1 directly from the current value of x.

  5. Since x was 5, it now becomes 4. (Because it is placed before the variable, it decrements the value immediately).

  6. System.out.println(x);

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

Output

4

Enter fullscreen mode Exit fullscreen mode

SQL

SELECT Example Without DISTINCT
If you omit the DISTINCT keyword, the SQL statement returns the "Country" value from all the records of the "Customers" table:

Example

SELECT Country FROM Customers;
Enter fullscreen mode Exit fullscreen mode

References :

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

Top comments (0)