Java String

Views:
 
Category: Entertainment
     
 

Presentation Description

This document provides relevant and useful information about Java strings. It covers a brief description about strings and how to create a string in Java. It also covers detailed information on String, StringBuffer, and StringBuilder classes and differences between them.

Comments

Presentation Transcript

slide 1:

JAVA STRING www.java2blog.com

slide 2:

PROJECT PROPOSAL CONTENT Overview String class String Constant pool StringBuffer class StringBuilder class

slide 3:

PROJECT PROPOSAL OVERVIEW A string is an object which shows the sequence of characters. In Java we can create a string using three classes String StringBuffer StringBuilder. All these classes implement the CharSequence interface.

slide 4:

PROJECT PROPOSAL STRING CLASS String class is present in java.lang package. String class provides a lot of methods for performing the operations on the strings. we can create String object using two ways: By new keyword By using String literal.

slide 5:

PROJECT PROPOSAL STRING CLASS If we create String Object through the new keyword. JVM will create String object into the Heap memory. String str1new String"Good Morning" If we create String object using String literal JVM will store it into the String constant pool. String str2"Good morning"

slide 6:

PROJECT PROPOSAL CONSTANT POOL String constant pool is a special memory area which is a part of Heap memory. When we create String object using String literal JVM first checks if String is already available in the String constant pool. If it exists JVM will create only reference to it. If it does not exist JVM will create new String object and store it in String constant pool.

slide 7:

PROJECT PROPOSAL STRINGBUFFER CLASS StringBuffer class is used to create a mutable string. Mutable String is a string that can be modified. It is synchronized class i.e Multiple threads cant invoke the StringBuffer class methods simultaneously. StringBuffer str1 StringBuffer"Welcome"

slide 8:

PROJECT PROPOSAL STRINGBUILDER CLASS StringBuilder class is used to create mutable strings. It is a non-synchronized class i.e. Multiple threads can call methods of StringBuilder simultaneously. StringBuilder str2new StringBuilder"Welcome"

slide 9:

PROJECT PROPOSAL DIFFERENCES The important difference between String StringBuffer and StringBuilder class is: String class is an immutable whereas StringBuffer and StringBuilder classes are mutable. StringBuffer class is thread-safe while StringBuilder class is not thread-safe class.

slide 10:

THANK YOU www.java2blog.com

authorStream Live Help