Karthikeya Boyini has Published 2383 Articles

Store unicode in a char variable in Java

karthikeya Boyini

karthikeya Boyini

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

1K+ Views

To store Unicode in a char variable, simply create a char variable.char c;Now assign unicode.char c = '\u00AB';The following is the complete example that shows what will get displayed: when Unicode is stored in a char variable and displayed.Example Live Demopublic class Demo {    public static void main(String []args) { ... Read More

Java Program to wrap a Primitive DataType in a Wrapper Object

karthikeya Boyini

karthikeya Boyini

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

368 Views

Every Java primitive data type has a class dedicated to it. These classes wrap the primitive data type into an object of that class. Therefore, it is known as wrapper classes.The following is the program that displays a Primitive DataType in a Wrapper Object.Example Live Demopublic class Demo {    public ... Read More

Parse and format to hexadecimal in Java

karthikeya Boyini

karthikeya Boyini

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

216 Views

To parse and format to hexadecimal in Java, we have used the BigInteger class. The java.math.BigInteger class provides operations analogues to all of Java's primitive integer operators and for all relevant methods from java.lang.Math.In the below example, we have taken BigInteger and created an object. With that, some values have ... Read More

Compare Two Java int Arrays in Java

karthikeya Boyini

karthikeya Boyini

Updated on 26-Jun-2020 10:53:52

447 Views

To compare two Java short arrays, use the Arrays.equals() method.Let us first declare and initialize some int arrays.int[] arr1 = new int[] { 33, 66, 12, 56, 99 }; int[] arr2 = new int[] { 33, 66, 12, 56, 99 }; int[] arr3 = new int[] { 33, 66, 15, ... Read More

How to assign int value to char variable in Java

karthikeya Boyini

karthikeya Boyini

Updated on 26-Jun-2020 10:52:45

2K+ Views

To assign int value to a char variable in Java would consider the ASCII value and display the associated character/ digit.Here, we have a char.char val;Now assign int value to it.val = 77;Now, when you will print the value of “val”, it would display the character associate with the value ... Read More

Java Program to create a boolean variable from string

karthikeya Boyini

karthikeya Boyini

Updated on 26-Jun-2020 10:47:48

238 Views

Use the parseBoolean() method to create a boolean variable from a string. Here for boolean variable, firstly take a boolean and pass the string to it using Boolean.parseBoolean().boolean val1 = Boolean.parseBoolean("TRUE");The parseBoolean() parses the string argument as a boolean. The boolean returned represents the value true if the string argument ... Read More

Parse and format a number to octal in Java

karthikeya Boyini

karthikeya Boyini

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

523 Views

To parse and format a number to octal, try the following code −Example Live Demopublic class Demo {    public static void main( String args[] ) {       int val = Integer.parseInt("150", 8);       System.out.println(val);       String str = Integer.toString(val, 8);       System.out.println(str); ... Read More

Random number generator in Java

karthikeya Boyini

karthikeya Boyini

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

2K+ Views

To generate random numbers in Java, use.import java.util.Random;Now, take Random class and create an object.Random num = new Random();Now, in a loop, use the nextInt() method since it is used to get the next random integer value. You can also set a range, like for 0 to 20, write it ... Read More

Check two numbers for equality in Java

karthikeya Boyini

karthikeya Boyini

Updated on 26-Jun-2020 10:44:37

10K+ Views

To check two numbers for equality in Java, we can use the Equals() method as well as the == operator.Firstly, let us set Integers.Integer val1 = new Integer(5); Integer val2 = new Integer(5);Now, to check whether they are equal or not, let us use the == operator.(val1 == val2)Let us ... Read More

Java Program to convert hexadecimal number to decimal number

karthikeya Boyini

karthikeya Boyini

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

298 Views

Use the parseInt() method with the second parameter as 16 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 hex string to decimal, use the 2nd syntax and add radix as 16, since hexadecimal radix ... Read More

Advertisements