Samual Sam has Published 2492 Articles

Java Program to convert decimal integer to hexadecimal number

Samual Sam

Samual Sam

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

282 Views

Use the toHexString() method to convert decimal to hexadecimal. The method returns a string representation of the integer argument as an unsigned integer in base 16. The following characters are used as hexadecimal digits:0123456789abcdef.The following is the syntax.String toHexString(int i)It has only single parameter.i − This is an integer to ... Read More

Integer.rotateLeft() method in Java

Samual Sam

Samual Sam

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

84 Views

The Integer.rotateLeft() method returns the value obtained by rotating the two's complement binary representation of the specified int value i left by the specified number of bits. The following is the syntax.int rotateLeft(int i, int distance)Here are the parameters.i − This is the int value.distance − This is the rotation ... Read More

Integer.reverseBytes() method in Java

Samual Sam

Samual Sam

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

60 Views

The method returns the value obtained by reversing the order of the bytes in the two's complement representation of the specified int value. Let us now see the syntax.int reverseBytes(int i)The following is the parameter.i − This is the int valueExample Live Demopublic class Demo {    public static void main(String ... Read More

Convert Java String Object to Boolean Object

Samual Sam

Samual Sam

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

1K+ Views

A string object can be created in Java using the string literal.String myStr = “Amit”;Another way to create a string object is using the new keyword.String myStr = new String("Hello!");We have used the first method to create a string object.String str = "true";Now, use the valueOf() method to convert String ... Read More

Read integers from console in Java

Samual Sam

Samual Sam

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

18K+ Views

To read integers from console, use Scanner class.Scanner myInput = new Scanner( System.in );Allow a use to add an integer using the nextInt() method.System.out.print( "Enter first integer: " ); int a = myInput.nextInt();In the same way, take another input in a new variable.System.out.print( "Enter second integer: " ); Int b ... Read More

Java Program to sort Short array

Samual Sam

Samual Sam

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

2K+ Views

To sort Short array, use the Arrays.sort() method.Let us first declare and initialize an unsorted Short array.short[] arr = new short[] { 35, 25, 18, 45, 77, 21, 3 };Now, let us short the array.Arrays.sort(arr);The following is the complete example that shows how to sort Short array in Java.Example Live Demoimport ... Read More

Convert byte primitive type to Byte object in Java

Samual Sam

Samual Sam

Updated on 26-Jun-2020 10:33:57

746 Views

To convert byte primitive type to Byte object, use the Byte constructor.Here is our byte primitive type.byte b = 100;Now let us convert it to Byte object.Byte res = new Byte(b);Let us see the complete example.Example Live Demopublic class Demo {    public static void main(String[] args) {       ... Read More

How to combine date and time from different MySQL columns to compare with the entire DateTime?

Samual Sam

Samual Sam

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

952 Views

You can combine date and time from different MySQL columns to compare with the entire date time with the help of CONCAT() function. The syntax is as follows −SELECT *FROM yourTableName WHERE CONCAT(yourDateColumnName, '', yourTimeColumnName) > 'yourDateTimeValue';To understand the above syntax, let us create a table. The query to create ... Read More

Fetch rows where a field value is less than 5 chars in MySQL?

Samual Sam

Samual Sam

Updated on 26-Jun-2020 10:29:35

511 Views

To fetch rows where a field value is less than 5 chars, you need to use LENGTH() function. The syntax is as follows −SELECT *FROM yourTableName WHERE LENGTH(yourColumnName) < 5;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create ... Read More

Create an Integer object in Java

Samual Sam

Samual Sam

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

5K+ Views

To create an Integer object in Java is quite easy. Let us learn about the following two ways for this purpose.Method1Example Live Demopublic class Demo {    public static void main(String []args) {       Integer obj = new Integer("199");       System.out.println(obj);    } }Output199Method2 −Now let us ... Read More

Advertisements