Samual Sam has Published 2310 Articles

Merge two sorted arrays in Python using heapq?

Samual Sam

Samual Sam

Updated on 26-Jun-2020 12:19:06

539 Views

In this section we will see how two sorted lists can be merged using the heapq module in Python. As an example, if list1 = [10, 20, 30, 40] and list2 = [100, 200, 300, 400, 500], then after merging it will return list3 = [10, 20, 30, 40, 100, ... Read More

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

Samual Sam

Samual Sam

Updated on 26-Jun-2020 12:16:51

7K+ Views

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

isLetterOrDigit() method in Java

Samual Sam

Samual Sam

Updated on 26-Jun-2020 12:15:23

194 Views

The isLetterOrDigit() method in Java returns TRUE if the entered value is a letter or digit.We have the following character.char val ='P';Now, let us check for letter or digit using if-else decision-making statement.if (Character.isLetterOrDigit(val)) {    System.out.println("Value is a letter or digit!"); } else {    System.out.println("Value is neither a ... Read More

Java Program to check whether the entered character a digit, white space, lower case or upper case character

Samual Sam

Samual Sam

Updated on 26-Jun-2020 12:13:37

985 Views

To check whether the entered character is a digit, whitespace, lowercase or uppercase, you need to check for the ASCII values.Let’s say we have a value in variable “val”, which is to be checked.For Lower Case.if(val >= 97 && val = 65 && val = 48 && val = 97 ... Read More

Copy char array to string in Java

Samual Sam

Samual Sam

Updated on 26-Jun-2020 12:11:17

15K+ Views

Use the valueOf() method in Java to copy char array to string. You can also use the copyValueOf() method, which represents the character sequence in the array specified. Here, you can specify the part of array to be copied.Let us first create a character array.char[] arr = { 'p', 'q', ... Read More

Parse and format a number to decimal in Java

Samual Sam

Samual Sam

Updated on 26-Jun-2020 10:55:20

455 Views

To parse and format a number to decimal, try the following code.Example Live Demopublic class Demo {    public static void main( String args[] ) {       int val = Integer.parseInt("5");       String str = Integer.toString(val);       System.out.println(str);    } }Output5In the above program, we ... Read More

Pass an integer by reference in Java

Samual Sam

Samual Sam

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

2K+ Views

To pass an integer by reference in Java, try the following code −Example Live Demopublic class Demo {    public static void display(int[] arr) {       arr[0] = arr[0] + 50;;    }    public static void main(String[] args) {       int val = 50;     ... Read More

Reverse an Integer in Java

Samual Sam

Samual Sam

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

1K+ Views

To reverse an integer in Java, try the following code −Example Live Demoimport java.lang.*; public class Demo {    public static void main(String[] args) {       int i = 239, rev = 0;       System.out.println("Original: " + i);       while(i != 0) {     ... Read More

How to convert Decimal to Hexadecimal in Java

Samual Sam

Samual Sam

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

6K+ Views

To convert decimal to hexadecimal, use any of the two methods i.e.Integer.toHexString() − It returns a string representation of the integer argument as an unsigned integer in base 16.Integer.parseInt() − It allows you to set the radix as well, for example, for hexadecimal set it as 16.Let us see an ... Read More

Convert string to a number in Java

Samual Sam

Samual Sam

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

2K+ Views

To convert a string to a number in Java, use the Integer.parseInt() method. First, let use create a String and set value.String str = "45";Now, take an Integer and use the Integer.parseInt() method.Integer i = Integer.parseInt(str);Let us see the complete example.Example Live Demopublic class Demo {    public static void main( ... Read More

Advertisements