String
- 06 December
Difference between replace() and replaceAll() in java
In this post, we will see difference between String’s replace() and replaceAll() methods in java. String’s replace() and replaceAll() both replace all occurences in the String. String’s replace() takes either two chars or two CharSequences as arguments and it will replace all occurrences of char or String but replaceAll() method takes regex String as argument […]
- 30 September
How to compare characters in Java
Learn about how to compare characters in java using different methods.
- 24 April
Add character to String in java
In this post, we will see how to add character to String in java. There are multiple ways to add character to String. Add character to the start of String You can add character at start of String using + operator. [crayon-6729b1c3eb862386921488/] Add character to the end of String You can add character at start […]
- 24 March
Initialize List of String in java
In this post, we will see how to initialize List of String in java. Can you initialize List of String as below: [crayon-6729b1c3eb97e455416933/] You can't because List is an interface and it can not be instantiated with new List(). You need to instantiate it with the class that implements the List interface. Here are the […]
- 17 March
New line character in java
In this post, we will see about new line character in java and how to add new line character to a String in different operating systems. Operating systems have different characters to denote the end of the line. Linux and new mac: In Linux, the end line is denoted by \n, also known as line […]
- 29 February
Java long to String
In this post, we will see how to convert long to String in java. There are lot of ways to convert long to String.Let’s see each one by one. Using Long.toString() You can use Long class toString() method to convert long to String. [crayon-6729b1c3ebb52412982707/] In case, Long can be null and you don’t want to […]
- 09 October
Find Vowels in a String
In this post, we will see how to find and count vowels in a string. Find Vowels in a String If any character in String satisfy below condition then it is vowel and we will add it to Hashset. character==’a’ || character==’A’ || character==’e’ || character==’E’ || character==’i’ || character==’I’ || character==’o’ || character==’O’ || […]
- 06 October
Java remove last character from string
Learn about how to remove last character from String in java using different ways.
- 06 October
Java isNumeric method
In this post, we will see how to implement isNumeric method in java. There are many way to check if String is numeric or not. Let’s see one by one. Using regular expressions You can use below regular expression to check if string is numeric or not. [-+]?\\d*\\.?\\d+ [crayon-6729b1c3ebde3755353058/] Output: 223 is numeric : true […]