Karthikeya Boyini has Published 2383 Articles

Display the limits of DataTypes in Java

karthikeya Boyini

karthikeya Boyini

Updated on 26-Jun-2020 10:27:50

523 Views

Every data type in Java has a minimum as well as maximum range, for example, for Integer.Minimum = -2147483648 Maximum = 2147483647Let’s say for Integer, if the value extends the maximum range display above, it leads to Overflow. However, if the value is less than the minimum range displayed above, ... Read More

Check whether the entered value is a digit or not in Java

karthikeya Boyini

karthikeya Boyini

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

3K+ Views

To check whether the entered value is a digit or not in Java, use the Character.isDigit() method.We have a character to be checked.char val = '5';Now let us use the Character.isDigit() method.if (Character.isDigit(val)) {    System.out.println("Character is a digit!"); } else {    System.out.println("Character is not a digit!"); }Let us ... Read More

Adding a column that doesn't exist in a query?

karthikeya Boyini

karthikeya Boyini

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

930 Views

Add a column that does not exist in a query, with the help of AS keyword. The syntax is as follows −SELECT yourColumnName1, yourColumnName2, ....N, yourValue AS yourColumnName, ....N' FROM yourTableName;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> ... Read More

Java Program to convert byte[] array to String

karthikeya Boyini

karthikeya Boyini

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

792 Views

To convert byte[] to String, firstly let us declare and initialize a byte array.// byte array byte[] arr = new byte[] {78, 79, 33};Now take a String and include the array in it.String str = new String(arr);Let us see the complete example to convert byte array to String.Example Live Demopublic class ... Read More

Convert Byte to numeric primitive data types in Java

karthikeya Boyini

karthikeya Boyini

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

312 Views

To convert Byte to numeric primitive data types, use the following methods −byteValue() shortValue() intValue() longValue() floatValue()Firstly, let us declare a Byte.Byte byteVal = new Byte("35");Now, let us see how to convert it to long type, for a simple example.long longVal = byteVal.longValue(); System.out.println(longVal);In the same way, you can convert ... Read More

Convert Java String to Short in Java

karthikeya Boyini

karthikeya Boyini

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

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

435 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

423 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

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

166 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

Advertisements