Samual Sam has Published 2310 Articles

Convert Short into String in Java

Samual Sam

Samual Sam

Updated on 26-Jun-2020 10:22:46

215 Views

Using toString() method to convert Short to string. Firstly, let us take a short primitive datatype and initialize a short value.short myShort = 55;Now let us include this value to the following Short object.Short s = new Short(myShort);Convert the above given Short to string using the toString() method as shown ... Read More

Java Program to convert String to short primitive

Samual Sam

Samual Sam

Updated on 26-Jun-2020 10:21:58

298 Views

Use the parseShort() method to convert String to short primitive. It parses the string argument as a signed short.Firstly, we have set a string.String str = "99";Now, we have taken a short primitive and included the string value.short val = Short.parseShort(str);The following is an example to convert String to short ... Read More

Java Program to compare two Byte Arrays

Samual Sam

Samual Sam

Updated on 26-Jun-2020 10:21:03

303 Views

To compare two Byte Arrays, use the Arrays.equals() method. Here we have declared and initialized a total of 4 arrays.byte[] arr1 = new byte[] { 11, 13, 30, 45, 77, 89 }; byte[] arr2 = new byte[] { 12, 13, 34, 87, 99, 33}; byte[] arr3 = new byte[] { ... Read More

Convert a byte to hexadecimal equivalent in Java

Samual Sam

Samual Sam

Updated on 26-Jun-2020 10:16:08

1K+ Views

To convert a byte to hexadecimal equivalent, use the toHexString() method in Java.Firstly, let us take a byte value.byte val1 = (byte)90;Before using the method, let us do some more manipulations. Mask the byte value now:int res = val1 & 0xFF;Let us now see the complete example and use the ... Read More

Check whether a character is Lowercase or not in Java

Samual Sam

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 ... Read More

Which query is efficient to check if MySQL Table is empty? COUNT(*) vs. LIMIT?

Samual Sam

Samual Sam

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

213 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, ... Read More

Java Program to convert an int to a boolean specifying the conversion values

Samual Sam

Samual Sam

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

138 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 ... Read More

Using GROUP BY and MAX on multiple columns in MySQL?

Samual Sam

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,   ... Read More

Display Minimum and Maximum values of datatype int in Java

Samual Sam

Samual Sam

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

210 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 ... Read More

How do I update NULL values in a field in MySQL?

Samual Sam

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 ... Read More

Advertisements