Tag «String»

Java String comparison. The difference between == and equals().

Many Java beginners find it difficult to differentiate between == operator and the “equals()” method when comparing String variables in Java. They assume that both operations perform the same function and either one can be used to compare two string variables. I have even seen many experienced programmers committing the mistake of using “==” to …

Extract substring from end of a Java String

Today I’ll show you how to extract last few characters (a substring) from a string in Java. Here is the code to do this. public class SubStringEx{ /** Method to get the substring of length n from the end of a string. @param inputString – String from which substring to be extracted. @param subStringLength- int …