Samual Sam has Published 2492 Articles

Difference between equals() vs equalsIgnoreCase() in Java

Samual Sam

Samual Sam

Updated on 26-Jun-2020 14:56:37

4K+ Views

Use equals() in Java to check for equality between two strings.Use equalsIgnoreCase() in Java to check for equality between two strings ignoring the case.Let’s say the following are our two strings −String one = "qwerty"; String two = "Qwerty";Both are equal, but the case is different. Since the method ignores ... Read More

Java Program to check for equality between two strings ignoring the case

Samual Sam

Samual Sam

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

172 Views

Use equalsIgnoreCase() in Java to check for equality between two strings ignoring the case.Let’s say the following are our two strings.String one = "rocky"; String two = "Rocky";Both are equal, but the case is different. Since the method ignore case, both of these strings would be considered equal.Here, we are ... Read More

Java Program to get a character located at the String's specified index

Samual Sam

Samual Sam

Updated on 26-Jun-2020 14:49:13

374 Views

Use the charAt() method in Java to get a character located at a specified index.Let’s say the following is our string.String str = "Laptop...";Finding character at 3rd position.str.charAt(2);The following is the final example.Example Live Demopublic class Demo {     public static void main(String[] args) {        String str = "Laptop...";        System.out.println("String: "+str);        System.out.println("Character ... Read More

Return all system properties in Java

Samual Sam

Samual Sam

Updated on 26-Jun-2020 14:43:51

1K+ Views

To return all the system properties in Java, firstly use the System.getProperties() method.java.util.Properties prop = System.getProperties();After that, use the list() method to list all of them.prop.list(System.out);Example Live Demopublic class MainClass {     public static void main(String[] args) {        java.util.Properties prop = System.getProperties();        prop.list(System.out);     } }Outputjava.runtime.name=OpenJDK Runtime Environment sun.boot.library.path=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0... java.vm.version=25.141-b16 java.vm.vendor=Oracle Corporation java.vendor.url=http://java.oracle.com/ ... Read More

Get all digits from a string in Java

Samual Sam

Samual Sam

Updated on 26-Jun-2020 14:38:18

627 Views

Let’s say the following is our string.String str = "DEMO98 TE4567XT";To display only the digits from the above string, we have used the replaceAll() method and replace all the characters with empty.str.replaceAll("\D", ""))The following is the final example that displays only digits from the string.Example Live Demopublic class Demo {    public static void main(String[] args) {     ... Read More

Java Program to concatenate Integers and a String

Samual Sam

Samual Sam

Updated on 26-Jun-2020 14:34:31

422 Views

To concatenate integers with a string value, you need to use the + operator.Let’s say the following is the string.String str = "Demo Text";Now, we will concatenate integer values with the above string.String res = str + 1 + 2 + 3 + 4 + 5;Example Live Demopublic class Demo {     public static void main(String[] args) { ... Read More

Thread-based parallelism in Python

Samual Sam

Samual Sam

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

311 Views

A thread in computer science is a set of instructions that can be managed independently by a scheduler, which is a part of operating system.The main function of Threading is to run multiple threads at a time. Threads means different tasks, function calls in the program and multiple threads run ... Read More

Synchronization and Pooling of processes in Python

Samual Sam

Samual Sam

Updated on 26-Jun-2020 12:44:50

587 Views

Synchronization between processesMultiprocessing is a package which supports spawning processes using an API. This package is used for both local and remote concurrencies. Using this module, programmer can use multiple processors on a given machine. It runs on Windows and UNIX os.All equivalent synchronization primitives are present in this package.Example ... Read More

Multiprocessing In Python

Samual Sam

Samual Sam

Updated on 26-Jun-2020 12:43:27

4K+ Views

The multiprocessing package supports spawning processes. It refers to a function that loads and executes a new child processes. For the child to terminate or to continue executing concurrent computing, then the current process hasto wait using an API, which is similar to threading module.IntroductionWhen we work with Multiprocessing, at ... Read More

Different Methods to find Prime Number in Python

Samual Sam

Samual Sam

Updated on 26-Jun-2020 12:31:53

1K+ Views

First we need to know what a prime number is.A prime number always a positive integer number and divisible by exactly 2 integers (1 and the number itself), 1 is not a prime number.Now we shall discuss some methods to find Prime Number.Method1Using For loopsExampledef primemethod1(number):    # Initialize a ... Read More

Advertisements