Samual Sam has Published 2492 Articles

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

Java Program to convert binary number to decimal number

Samual Sam

Samual Sam

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

514 Views

Use the parseInt() method with the second parameter as 2 since it is the radix value. The parseInt() method has the following two forms.static int parseInt(String s) static int parseInt(String s, int radix)To convert binary to decimal, use the 2nd syntax and add radix as 2, since binary radix is ... Read More

Check whether a character is Lowercase or not in Java

Samual Sam

Samual Sam

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

9K+ 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

161 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

92 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

150 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

Display the minimum of three integer values in Java

Samual Sam

Samual Sam

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

280 Views

The following is an example displaying the minimum of three integer values.Example Live Demopublic class Demo {    public static void main(String[] args) {       int val1 = 99;       int val2 = 87;       int val3 = 130;       System.out.println("Number 1 = ... Read More

Default value of primitive data types in Java

Samual Sam

Samual Sam

Updated on 26-Jun-2020 10:06:32

12K+ Views

Primitive datatypes are predefined by the language and named by a keyword in Java. Here is an example to display the default value of primitive data types.Example Live Demopublic class Demo {    static boolean val1;    static double val2;    static float val3;    static int val4;    static long ... Read More

Advertisements