Java String Tutorial
String Class is a widely used class in java. String Class represents a bunch of characters and is similar to a character array. String class has almost a dozen constructors and can be used to create String objects. You can check the
Difference String StringBuffer and StringBuilder
We will see the differences between String, StringBuffer and StringBuilder. The main differences are related to thread safe nature and performance. Difference String StringBuffer and StringBuilder String 1. String is immutable – So string is Thread Safe. 2. Any operations on String,
String.format java example
In this post we will see String.format java examples. Format method in String returns a formatted string using the specified format string and arguments. [crayon-607d6b4184833938611207/] Params : format – the format string args – Arguments referenced by the format specifiers in the
String trim example
String trim method is used to remove the leading and trailing white spaces in a String. [crayon-607d6b4184e6f792108038/] String trim method example [crayon-607d6b4184e78708300929/] Output [crayon-607d6b4184e7e959094402/] Reference 1. String trim() API
String concat example
Concat method of String in java is used to add a new String at the end of the original String. [crayon-607d6b418531e774754737/] String concat example [crayon-607d6b4185327802615144/] Output [crayon-607d6b418532d060376063/] Reference 1. String API
String endsWith example
String endsWith is used to check if a String ends with the given suffix. [crayon-607d6b41857e3978320893/] endsWith() method returns a boolean value based on the suffix passed String endsWith example [crayon-607d6b41857ec220301623/] Output [crayon-607d6b41857f2652788723/] Reference 1. String API
String startsWith example
String startsWith method is used to check if a String starts with a specified substring. Startswith method has 2 variations and we will see both these. [crayon-607d6b4185e17790868257/] [crayon-607d6b4185e25170300385-i/] checks if the String starts with the given prefix. [crayon-607d6b4185e2e215213151-i/] checks if the sub
String replace methods example
String replace methods are used to replace a part of string with a new string. We have 4 variations for replace in String [crayon-607d6b4186713657303550/] [crayon-607d6b418671d839847629-i/] returns a new String with the oldChar replaced with a newChar that was specified. [crayon-607d6b4186723391360255-i/] returns a
String lastIndexOf example
String lastIndexOf returns the index of the last occurrence of the given String for specified conditions searching backward. String lastIndexOf method can be used with multiple types of parameters as shown below [crayon-607d6b4186f14163478436/] 1. [crayon-607d6b4186f1d989579448-i/] returns the index of the last occurrence
String indexOf example
String indexOf returns the index of the given String for specified conditions. String indexOf method can be used with multiple types of parameters as shown below [crayon-607d6b4187564885582969/] 1. [crayon-607d6b418756d851114243-i/] returns the index of the first occurrence of the specified character. 2. [crayon-607d6b4187572948422409-i/]