Check Whether a Character is Lowercase in Java

Samual Sam
Updated on 26-Jun-2020 10:13:14

11K+ Views

To check whether a character is in Lowercase or not in Java, use the Character.isLowerCase() method.We have a character to be checked.char val = 'q';Now let us use the Character.isLowerCase() method.if (Character.isLowerCase(val)) {    System.out.println("Character is in Lowercase!"); }else {    System.out.println("Character is in Uppercase!"); }Let us see the complete example now to check for Lowercase in Java.Example Live Demopublic class Demo {    public static void main(String []args) {       System.out.println("Checking for Lowercase character...");       char val = 'q';       System.out.println("Character: "+val);       if (Character.isLowerCase(val)) {          System.out.println("Character is ... Read More

Check If a Table Is Empty in MySQL Using EXISTS

karthikeya Boyini
Updated on 26-Jun-2020 10:13:06

3K+ Views

The following is the syntax to check whether a table is empty or not using MySQL EXISTS −SELECT EXISTS(SELECT 1 FROM yourTableName);ExampleFirst, let us create a table. The query to create a table is as follows −mysql> create table ReturnDemo    -> (    -> Id int,    -> Name varchar(10)    -> ); Query OK, 0 rows affected (0.79 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into ReturnDemo values(100, 'Larry'); Query OK, 1 row affected (0.18 sec) mysql> insert into ReturnDemo values(101, 'Bob'); Query OK, 1 row affected (0.28 sec) ... Read More

Convert Integer to Boolean in Java

karthikeya Boyini
Updated on 26-Jun-2020 10:12:38

11K+ Views

To convert integer to boolean, firstly let us initialize an integer.int val = 100;Now we will declare a variable with primitive boolean. While declaration, we will initialize it with the val value comparing it with an integer using the == operator. If the value matches, the value “True” is returned, else “False” is returned.boolean bool = (val == 100);Let us now see the complete example displaying how to convert integer to boolean.Example Live Demopublic class Demo {    public static void main(String[] args) {       int val = 100;       System.out.println("Integer: "+val);       boolean bool ... Read More

Efficient Query to Check if MySQL Table is Empty: COUNT vs LIMIT

Samual Sam
Updated on 26-Jun-2020 10:12:25

219 Views

If you use COUNT(*) around the LEAST() then MySQL scans at least one index, therefore avoid LEAST(COUNT(*)) and use LIMIT.Let us first create a table. The query to create a table is as follows −mysql> create table ReturnDemo -> ( -> Id int, -> Name varchar(10) -> ); Query OK, 0 rows affected (0.79 sec)ExampleNow you can insert some records in the table using insert command. The query is as follows −mysql> insert into ReturnDemo values(100, 'Larry'); Query OK, 1 row affected (0.18 sec) mysql> insert into ReturnDemo values(101, 'Bob'); Query OK, 1 row affected (0.28 sec) mysql> insert into ... Read More

Convert Int to Boolean Specifying Conversion Values in Java

Samual Sam
Updated on 26-Jun-2020 10:12:14

144 Views

To convert int to boolean, let us first take the following int.int one = 1; int two = 1; int three = 0;We have nested if-else statement to display the true or false values. Here, the value “one” is the same as “two” i.e. 1; therefore, the following works −else if (one.equals(two)) {    System.out.println(true); }The above display “true” and in this way we converted int to boolean.Let us now see the complete example to learn how to convert int to Boolean.Example Live Demopublic class Demo {    public static void main(String[] args) {       int one = 1; ... Read More

Perform XOR on a Set of Booleans in Java

karthikeya Boyini
Updated on 26-Jun-2020 10:11:38

210 Views

To perform XOR on a set of Booleans, firstly let us consider the following Boolean array.boolean[] arr = { true, true, false };Let us now create a nested loop and within that perform XOR operation.for (boolean one : arr) {    for (boolean two: arr) {       // XOR       boolean res = one ^ two;    } }Here is the entire example to displayXOR on a set of Booleans.Example Live Demopublic class Demo {    public static void main(String[] args) {       // boolean array       boolean[] arr = { true, true, ... Read More

Using GROUP BY and MAX on Multiple Columns in MySQL

Samual Sam
Updated on 26-Jun-2020 10:09:59

2K+ Views

To understand the GROUP BY and MAX on multiple columns, let us first create a table. The query to create a table is as follows −mysql> create table GroupByMaxDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> CategoryId int,    -> Value1 int,    -> Value2 int    -> ); Query OK, 0 rows affected (0.68 sec)ExampleInsert some records in the table using insert command. The query is as follows −mysql> insert into GroupByMaxDemo(CategoryId, Value1, Value2) values(10, 100, 50); Query OK, 1 row affected (0.15 sec) mysql> insert into GroupByMaxDemo(CategoryId, Value1, Value2) values(10, 100, ... Read More

Check for Integer Overflow in Java

karthikeya Boyini
Updated on 26-Jun-2020 10:09:42

7K+ Views

To check for Integer overflow, we need to check the Integer.MAX_VALUE, which is the maximum value of an integer in Java.Let us see an example wherein integers are added and if the sum is more than the Integer.MAX_VALUE, then an exception is thrown.Example Live Demopublic class Demo {    public static void main(String[] args) {       int val1 = 9898989;       int val2 = 6789054;       System.out.println("Value1: "+val1);       System.out.println("Value2: "+val2);       long sum = (long)val1 + (long)val2;       if (sum > Integer.MAX_VALUE) {          throw ... Read More

Display Minimum and Maximum Values of Datatype int in Java

Samual Sam
Updated on 26-Jun-2020 10:09:07

216 Views

To get the minimum value of datatype int in Java, use the following −Integer.MIN_VALUETo get the maximum value of datatype int in Java, use the following −Integer.MAX_VALUELet us now implement this in our example.Example Live Demopublic class Demo {    public static void main(String[] args) {       int val1 = 20;       int val2 = 3000;       System.out.println("Value1: "+val1);       System.out.println("Value2: "+val2);       System.out.println("Maximum value: "+Integer.MIN_VALUE);       System.out.println("Minimum value: "+Integer.MAX_VALUE);    } }OutputValue1: 20 Value2: 3000 Maximum value: -2147483648 Minimum value: 2147483647

Update Null Values in a Field in MySQL

Samual Sam
Updated on 26-Jun-2020 10:08:40

3K+ Views

Let us first create a table −mysql> create table OrderDemo    -> (    -> OrderId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> OrderPrice int,    -> OrderDatetime datetime    -> ); Query OK, 0 rows affected (0.66 sec)ExampleNow you can insert some records in the table using insert command. The query is as follows −mysql> insert into OrderDemo(OrderPrice, OrderDatetime) values(200, '2016-09-12'); Query OK, 1 row affected (0.24 sec) mysql> insert into OrderDemo(OrderPrice, OrderDatetime) values(NULL, '2002-11-18'); Query OK, 1 row affected (0.26 sec) mysql> insert into OrderDemo(OrderPrice, OrderDatetime) values(1000, '2017-12-28'); Query OK, 1 row affected (0.15 sec)Display all records ... Read More

Advertisements