Core java
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 […]
07 MayJava String lastIndexOf example
String’s lastIndexOf method is used to find out last index of any character or sub string. lastIndexOf method can take char or string as argument and also you can provide fromIndex also. Methods: public int lastIndexOf(int ch) returns index of last occurrence of character within String public int lastIndexOf(int ch,int fromIndex) returns index of last occurrence […]
07 MayJava String indexOf example
String’s indexOf method is used to find out index of any character or sub string. indexOf method can take char or string as argument and also you can provide fromIndex(Index after which you want to use indexOf method) also. Methods: public int indexOf(int ch) returns index of first occurrence of character within String public int […]
06 MayJava String substring example
String’s substring method is used to fetch part of a String.It returns a new String which is substring of given String. substring is nothing but subset of given String. There are two overloaded methods for substring. Method Signature: public String substring(int startIndex) It returns a new String which is substring of given String from specified […]
06 MayJava String contains example
String’s contains method checks if sequence of characters can be found in String. It returns true if character sequence is present in String else return false. Method Signature: public boolean contains(CharSequence s) String contains Example: package org.arpit.java2blog; public class StringContainsMethodExample { public static void main(String[] args) { String str = "Hello world from java2blog.com"; if […]
06 MayJava String concatenate example
String concatenate is a way to join multiple Strings to create large String. There are many places where we use to do String concatenate. For example: When you override toString() method of object, you concatenate multiple attributes to create a big String that represent that object. 3 ways to concatenate String Using + operator Using String’s […]