Java String

Category Archives: Java String

Methods in Java String Class

Java String class is method rich. Let’s see, available methods in Java string class. We have a lot of methods in Java, we can perform operations on the string such as trimming, concatenating, converting, comparing, replacing strings etc.   Methods in Java String Class 1. Java String Concat() method – This method is used to contact … Continue reading Methods in Java String Class

StringBuilder class in Java

StringBuilder class is a mutable class, unlike the String class which is immutable. StringBuilder class is same like StringBuffer class excerpts String Builder is non-synchronized class. StringBuilder class is mostly used when we want to concatenate many strings continuously and/or treat them like variable-length arrays. String appends become increasingly expensive as strings become longer. More and more … Continue reading StringBuilder class in Java

Java String Comparison

Let’s the Java String Comparison. There are many ways to compare the Strings in Java. We can compare string in java on the basis of content and reference. Note the following ways to compare Strings – Using equals() method Using equalsIgnoreCase() method Using compareTo() method Using == Operator   Java String Comparison Let’s discuss the methods in details … Continue reading Java String Comparison

String Class in Java

The String class in java is the most popular class in the Java library. The string is a sequence of characters. i.e “Java” is 4 character string. String class encapsulates under the java.lang package. The string is immutable it means once a string object is created it cannot be changed. String class is used to create the … Continue reading String Class in Java

StringBuilder vs StringBuffer

Let’s discuss StringBuilder vs StringBuffer in Java. StringBuilder Class and StringBuffer Class both classes are mutable classes, unlike the String class which is immutable. The main difference between StringBuffer and StringBuilder can be explained on the basis of four parameters, synchronization, speed, thread-safety, and availability. StringBuffer is synchronized and that’s why thread-safe, but StringBuilder is … Continue reading StringBuilder vs StringBuffer

Reverse String Program in Java – Java Interview Question

This is common interview question, How to reverse String in Java without inbuilt method. You have inbuilt method to reverse String in Java library, StringBuffer and StringBuilder class with reverse() method which can be used to reverse String in Java.   In this Java tutorial, you will see How to reverse String using StringBuffer, StringBuilder and … Continue reading Reverse String Program in Java – Java Interview Question

String Concatenation in Java

In Java String Class we can perform the concatenation of Strings, In concatenation process we form a new String which is the combination of multiple Strings. There are many ways to concatenate the Strings. Concatenation operator (+) StringBuffer class StringBuilder class String.concat() function Let’s discuss the each way to concatenate the String in Java. Using … Continue reading String Concatenation in Java