• 06 May

    Java 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: [crayon-60951ecf1d58a380230544/] It returns a new String which is substring of given String from specified startIndex(Inclusive) [crayon-60951ecf1d594864444997/] It […]

  • 14 May

    Java String equalsIgnoreCase example

    String’s equalsIgnoreCase method is similar to equals method but it ignores case. So if Strings have different cases, then also it will considered as equals. For example: [crayon-60951ecf1de81283334703/] str1.equalsIgnoreCase(str2) will return true. Method Signature: [crayon-60951ecf1de88758609274/] String equalsIgnoreCase Example: [crayon-60951ecf1de8b101237603/] When you run above program, you will get below output: [crayon-60951ecf1de8e806424249/]

  • 10 May

    Java 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: [crayon-60951ecf1e2c2408415777/] String isEmpty Example: [crayon-60951ecf1e2c9812428422/] When you run above program, you will get below output: [crayon-60951ecf1e2cc732104264/]

  • 14 May

    Java String equals example

    String’s equals method compares String with specified object. It checks if both have same character sequence. It is generally used to compare two Strings. Method Signature: [crayon-60951ecf1e683839615107/] String equals Example: [crayon-60951ecf1e689111859998/] When you run above program, you will get below output: [crayon-60951ecf1e68c577351062/]

  • 09 May

    Java String length example

    String’s length method is used to calculate length of String. It returns number of character in the String. Method Signature: [crayon-60951ecf1ea19869464350/] String length Example: [crayon-60951ecf1ea1f886913306/] When you run above program, you will get below output: [crayon-60951ecf1ea22018700422/]

  • 07 May

    Why 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. [crayon-60951ecf1ed72347761252/] As you can see, value of str1 did not change. It created another String object with value “Hellojava2blog” but […]