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());
}
}
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 namedtxtof typeStringand assigns it the entire alphabet in uppercase letters. -
txt.length(): Calls the built-inlength()method on the string object, which counts every character stored insidetxt. -
System.out.println(...): Outputs the resulting string concatenation—combining the descriptive text with the number26—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;
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;
References :
https://www.w3schools.com/sql/sql_orderby.asp
https://www.w3schools.com/java/java_examples.asp
Top comments (0)