Author: Arpit Mandliya
- 14 May
Java String contentEquals example
String’s contentEquals method is used to compare String with StringBuffer. It returns boolean datatype. Method syntax: [crayon-6782672975571804657089/] String contentEquals Example: [crayon-6782672975577780713687/] When you run above program, you will get below output: [crayon-6782672975579204654598/] Please note that contentEquals method is case sensitive as you can see in above example
- 13 May
Java String endsWith example
String’s endWith method checks if String ends with specific suffix. It returns boolean datatype. Method syntax: [crayon-6782672975788542852123/] String endsWith Example: [crayon-678267297578c550852100/] When you run above program, you will get below output: [crayon-678267297578e123155884/] Please note that endsWith method is case sensitive as you can see in above example
- 12 May
Java String startsWith example
String’s startsWith method checks if String starts with specific prefix. It returns boolean datatype. Method Signature: [crayon-6782672975831050275769/] String startsWith Example: [crayon-6782672975833044607904/] When you run above program, you will get below output: [crayon-6782672975834480814634/] Please note that startsWith method is case sensitive as you can see in above example
- 12 May
Java String charAt example
String’s charAt method returns char value present at specified index. String is nothing but Sequence of char values and it starts with index 0. Method Signature: [crayon-67826729758d6445856010/] String charAt Example: [crayon-67826729758d9509070354/] When you run above program, you will get below output: [crayon-67826729758da869506825/]
- 11 May
Java 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: [crayon-6782672975964046930609/] When you run above program, you […]
- 10 May
How 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: Using String […]
- 10 May
Java 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: [crayon-6782672975bcf836078689/] Parameters: ignoreCase: It is boolean field to indicate whether to ignore case or […]
- 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-6782672975c85358368734/] String isEmpty Example: [crayon-6782672975c88653051389/] When you run above program, you will get below output: [crayon-6782672975c89587141162/]
- 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-6782672975d14157385573/] String length Example: [crayon-6782672975d16190784844/] When you run above program, you will get below output: [crayon-6782672975d17818186428/]