Core java
11 MayJava String trim example
String’s trim method is used to remove leading and trailing space. Sometimes, you get extra leading or trailing space and your program does not work as expected. It returns String object after removing leading and trailing spaces. String’s trim method does not remove middle spaces. String trim example: package org.arpit.java2blog; public class StringTrimExample { public […]
10 MayHow to check if two Strings are Anagrams in Java
In this post, we will see how to check if two Strings are Anagrams in java. Anagrams mean if two Strings have the same characters but in a different order. For example: Angel and Angle are anagrams There are many ways to check if Strings are anagrams in java. Some of them are: [toc] Using […]
10 MayJava String regionMatches example
String’s regionMatches is used to compare substring of one string to substring of another.Here region may be refer to substring of String, so we are comparing regions of one string with another. Method Syntax: There are two overloaded version of regionMatches: // Case sensitive public boolean regionMatches(int toffset, String other, int ooffset, int len): // […]
10 MayJava String isEmpty example
String’s isEmpty method checks if length of string is 0 or not. It returns true if length of String is 0 else return false. Method Signature: public boolean isEmpty() String isEmpty Example: package org.arpit.java2blog; public class StringIsEmptyExample { /* * @Author : Arpit Mandliya */ public static void main(String[] args) { String str1=""; String str2="java2blog"; […]
09 MayJava String length example
String’s length method is used to calculate length of String. It returns number of character in the String. Method Signature: public int length() String length Example: package org.arpit.java2blog; public class StringLengthExample { /* * @Author: Arpit Mandliya */ public static void main(String[] args) { // 1st String str1 = "Hello world from java2blog.com"; // 2nd […]
08 MayJava Program to find duplicate Characters in a String
In this post, we will see how to find duplicate Characters in a String. Approach: Create a HashMap and character of String will be inserted as key and its count as value. If Hashamap already contains char,increase its count by 1, else put char in HashMap If value of Char is more than 1, that means it […]
08 MayJava String join example
String’s join method can be used to join various String by the delimiter. It is introduced in java 8. For example: We need to join various Strings by “,”. You can use join method as String.join(",","java","blog","tutorials"); // Output "java,blog,tutorial" There are two overloaded variants of String’s join method: public static String join(CharSequence delimiter, CharSequence... elements) […]
08 MayGuía práctica de apuestas Sportium: matemáticas y trucos de operador
Esta no es una reseña genérica de casino — este es un manual práctico de operador para los jugadores de Sportium apuestas. Aquí encontrarás todo lo necesario para gestionar tu cuenta, calcular bonos, resolver problemas y exprimir al máximo tu experiencia. Getting Ready Verifica que tienes conexión a internet estable y un dispositivo compatible (PC, […]
07 MayWhy String is immutable in java
String class is immutable in java. If you take dictionary meaning of immutable, it means unable to be changed or unchanging over time, so String is unchangeable or unmodifiable in java. Let’s understand with example. String str1="Hello"; str1.concat("java2blog"); System.out.println(str1); // Output will be Hello As you can see, value of str1 did not change. It […]