Difference between String buffer and String builder in Java

Mahesh Parahar
Updated on 05-Dec-2023 10:02:00

10K+ Views

String buffer and StringBuilder both are mutable classes which can be used to do operation on string objects such as reverse of string, concating string and etc. We can modify string without creating a new object of the string. A string buffer is thread-safe whereas string builder is not thread-safe. Therefore, it is faster than a string buffer. Also, a string concat + operator internally uses StringBuffer or StringBuilder class. Below are the differences. Sr. No. Key String Buffer String Builder 1 Basic StringBuffer was introduced with the initial release of Java It was introduced in Java 5 2 Synchronized It is synchronized It is not synchronized 3 Performance It is thread-safe. So, multiple threads can’t ... Read More

Difference between List and Set in Java

Mahesh Parahar
Updated on 05-Dec-2023 09:48:36

2K+ Views

List and Set both interface belongs to the Collection framework. Both interfaces extend the Collection interface. They both are used to store a collection of objects as a single unit. Before jdk1.2, we used to use Arrays, Vectors, and Hashtable for grouping objects as a single unit. Sr. No. Key List Set 1 Positional Access The list provides positional access of the elements in the collection. Set doesn't provide positional access to the elements in the collection. 2 Implementation Implementation of List are ArrayList, LinkedList, Vector ,Stack. Implementation of a set interface is HashSet and LinkedHashSet. 3 Duplicate We can store the duplicate elements in the list. We can’t store duplicate elements in Set. 4 Ordering List maintains ... Read More

What is the easiest way to reverse a String in Java?

Maruthi Krishna
Updated on 05-Dec-2023 09:29:13


Built-in reverse() method The StringBuffer class provides you a method named reverse(). It reverses the contents of the current StringBuffer object and returns the resultant StringBuffer object. It is the easiest way to reverse a Sting using Java. To do so − Instantiate the StringBuffer class by passing the required String as a parameter. Invoke the reverse() method od the created object. Convert it into String again using the toString() method. Example public class Sample { public static void main(String args[]) { String str = new String("Hello how are you"); StringBuffer sb = new ... Read More

How to validate given date formats like MM-DD-YYYY using regex in java?

Maruthi Krishna
Updated on 05-Dec-2023 09:18:50

3K+ Views

The java.util.regex package of java provides various classes to find particular patterns in character sequences. The pattern class of this package is a compiled representation of a regular expression. To match a regular expression with a String this class provides two methods namely − compile() − This method accepts a string representing a regular expression and returns an object of the Pattern object. matcher() − This method accepts a String value and creates a matcher object which matches the given String to the pattern represented by the current pattern object. Following is the regular expression to match date in dd-MM-yyyy format − ^(1[0-2]|0[1-9])/(3[01]|[12][0-9]|0[1-9])/[0-9]{4}$ Therefore, to validate ... Read More

What is the full form of EPROM?

Praveen Varghese Thomas
Updated on 04-Dec-2023 16:03:52


Introduction Erasable Programmable Read-Only Memory (EPROM) is a non-volatile memory chip type that can be modified, deleted, and reconstructed more than once. In the past, embedded systems, microcontrollers, and other electronic devices frequently employed EPROMs to store firmware and other vital system data. Using a network of transistors and capacitors, EPROMs store binary data. The erasability of EPROMs distinguishes them from other varieties of memory chips. The chip must be removed from the gadget and placed in a specialized rubber machine, where it will be subjected to ultraviolet light for the duration of the several-minute-long erasing operation. Working Principle ... Read More

What is the full form of FCI?

Praveen Varghese Thomas
Updated on 04-Dec-2023 16:02:55


Introduction Food Corporation of India (FCI) was founded in 1965 to guarantee an adequate food supply for the nation's expanding population. The FCI is in charge of running a nationwide system of stores and depots where food grains are kept. Through its extensive transportation network, the FCI also plays a significant part in distributing these grains to different regions of the nation. In addition to its primary duties, the FCI also offers a variety of additional services, such as the implementation of welfare programs based on food, the administration of food- related crises, and the advancement of food grain ... Read More

What is the full form of FDC?

Praveen Varghese Thomas
Updated on 04-Dec-2023 16:02:01


Introduction Floppy Disk Controller (FDC) is an electronic device used to manage the reading and writing of data on floppy disks. In the 1980s and 1990s, floppy disks—a type of magnetic storage medium—were frequently used to store data. The floppy disk drive (FDC) and the computer's central processor unit (CPU) are both connected through the FDC. It regulates both the formatting of data on the disk and the data flow between the computer and the disk drive. The FDC gives instructions to the disk drive so that it may spin the disk and place the read-write head where it ... Read More

What is the full form of FHR?

Praveen Varghese Thomas
Updated on 04-Dec-2023 16:01:11


Introduction Foetal heart rate (FHR) is the heart rate of the foetus. With the advent of technology, medical science has advanced significantly, and we can now monitor the process of childbirth with incredible accuracy and attention. Earlier, even the notion of trying to understand what was happening while the foetus developed inside the womb would have been outlandish. But today, not only can we find the gender of the baby with 100% accuracy before birth, but we can also monitor the baby’s development at every stage of the way. Medical check-ups and care during pregnancy is known as prenatal ... Read More

What is the full form of FIPB?

Praveen Varghese Thomas
Updated on 04-Dec-2023 15:59:42


Introduction Foreign Investment Promotion Board (FIPB) was a government body in India responsible for processing foreign direct investment proposals and granting approvals until it was abolished in 2017. The board played a crucial role in regulating and promoting foreign investments in the country and was responsible for approving foreign investments that were not covered under the automatic route. The FIPB reviewed foreign investment proposals and granted approvals based on their potential impact on the economy and national security. Its primary objective was to attract foreign investors to India and to facilitate their entry into the Indian market, while ensuring ... Read More

What is the full form of FIR?

Praveen Varghese Thomas
Updated on 04-Dec-2023 15:58:18


Introduction First Information Report (FIR) is a written document that is prepared by the police in India, Bangladesh, and other countries to record the details of a crime or an offense that has been committed. The FIR is typically filed by the victim or a witness to the crime, and it is considered the first step in the legal process of investigating and prosecuting a crime. The information recorded in the FIR includes the date, time, and location of the crime, the identity of the victim and the accused, and a description of the offense. Purpose of FIR The ... Read More

1 2 3 4 5 ... 11543 Next