Karthikeya Boyini has Published 2193 Articles

Convert Java String to Short in Java

karthikeya Boyini

karthikeya Boyini

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

7K+ Views

Use valueOf() method to convert a String in Java to Short.Let us take a string.The following is an example −String myStr = "5";Now take Short object and use the valueOf() method. The argument should be the string we declared above.The following is an example.Short myShort = Short.valueOf(myStr);Let us now see ... Read More

Convert short primitive type to Short object in Java

karthikeya Boyini

karthikeya Boyini

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

592 Views

Let us first create a short primitive type and assign a value.short val = 30;Now, create a Short object and set the above short type to it.Short myShort = new Short(val);The following is the complete example to convert short primitive type to Short object using Short constructor.Example Live Demopublic class Demo ... Read More

Java Program to convert byte to string

karthikeya Boyini

karthikeya Boyini

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

555 Views

In Java, there are different ways to convert byte to string.Using toString() method, you can easily convert byte to string as shown below −Example Live Demopublic class Demo {    public static void main(String[] args) {       byte res = 87;       // byte to string   ... Read More

How to add auto-increment to column in MySQL database using PhpMyAdmin?

karthikeya Boyini

karthikeya Boyini

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

10K+ Views

You can add auto_increment to a column in MySQL database with the help of ALTER command.The syntax is as follows −ALTER TABLE yourTableName MODIFY yourColumnName INT NOT NULL AUTO_INCREMENT;To open PhpMyAdmin on localhost, you need to type the following on localhost and press enter −localhost/phpmyadminThe screenshot is as follows −Above, ... Read More

Java Program to convert an UNSIGNED byte to a JAVA type

karthikeya Boyini

karthikeya Boyini

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

293 Views

Firstly, let us declare byte values.byte val1 = 127; byte val2 = -128;To convert the above given unsigned byte, you can use the following. Here, we are first implementing it for the variable “val1”.(int) val1 & 0xFFNow for the second variable “val2”.(int) val2 & 0xFFLet us see the complete example ... Read More

Integer.lowestOneBit() method in Java

karthikeya Boyini

karthikeya Boyini

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

111 Views

The method Integer.lowestOneBit() returns an int value with at most a single one-bit, in the position of the lowest-order ("rightmost") one-bit in the specified int value.Here we have a decimal value 294, whose binary is −100100110The lowest one bit is calculated using the lowestOneBit() method in Java.Example Live Demopublic class Demo ... Read More

Java Program to multiply integers and check for overflow

karthikeya Boyini

karthikeya Boyini

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

950 Views

To check for Integer overflow, we need to check the Integer.MAX_VALUE with the multiplied integers result, Here, Integer.MAX_VALUE is the maximum value of an integer in Java.Let us see an example wherein integers are multiplied and if the result is more than the Integer.MAX_VALUE, then an exception is thrown.The following ... Read More

Check if a table is empty or not in MySQL using EXISTS

karthikeya Boyini

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

Java Program to convert integer to boolean

karthikeya Boyini

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

Java Program to perform an XOR on a set of Booleans

karthikeya Boyini

karthikeya Boyini

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

195 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) {       // ... Read More

Advertisements