DEV Community

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

Posted on

One Commit at a Time ! Series - 17

JAVA

public class Main {
  public static void main(String[] args) {
    String txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    System.out.println("The length of the txt string is: " + txt.length());
  }
}
Enter fullscreen mode Exit fullscreen mode

Explanation :

This Java program calculates and prints the number of characters inside a given text string.

  • public class Main: Defines the main container class for the program, which Java requires for all code execution.
  • public static void main(String[] args): The entry point or starting mechanism where the Java Virtual Machine begins running the code.
  • String txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";: Declares a variable named txt of type String and assigns it the entire alphabet in uppercase letters.
  • txt.length(): Calls the built-in length() method on the string object, which counts every character stored inside txt.
  • System.out.println(...): Outputs the resulting string concatenation—combining the descriptive text with the number 26—directly to your console screen.

SQL

ORDER BY Several Columns
The following SQL statement selects all customers from the "Customers" table - and sorts it by the "Country" and the "CustomerName" column.

This means that it sorts it first by Country, and if some records have the same Country, it sorts them by CustomerName:

SELECT * FROM Customers
ORDER BY Country, CustomerName;
Enter fullscreen mode Exit fullscreen mode

Combine ASC and DESC
The following SQL statement selects all customers from the "Customers" table, and sorts it ASCENDING by the "Country" and DESCENDING by the "CustomerName" column:

SELECT * FROM Customers
ORDER BY Country ASC, CustomerName DESC;
Enter fullscreen mode Exit fullscreen mode

References :
https://www.w3schools.com/sql/sql_orderby.asp
https://www.w3schools.com/java/java_examples.asp

Top comments (0)