Samual Sam has Published 2310 Articles

Difference between equals() vs equalsIgnoreCase() in Java

Samual Sam

Samual Sam

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

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

234 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

457 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

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

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

516 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

Synchronization and Pooling of processes in Python

Samual Sam

Samual Sam

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

813 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

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

JSON Formatting in Python

Samual Sam

Samual Sam

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

9K+ Views

The JSON (Java Script Object Notation) is light weight, well accepted data interchange format. Using JSON formatting techniques in Python, we can convert JSON strings to Python objects, and also convert Python Objects to JSON strings.To use these functionalities, we need to use the json module of Python. The json ... Read More

Java Program to compare two Java char Arrays

Samual Sam

Samual Sam

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

386 Views

To compare two Java char arrays, use the Arrays.equals() method.Let us first declare and initialize some char arrays.char[] arr1 = new char[] { 'p', 'q', 'r' }; char[] arr2 = new char[] { 'p', 'r', 's' }; char[] arr3 = new char[] { 'p', 'q', 'r' };Now let us compare ... Read More

Advertisements