Java strings
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
181
On Slideshare
181
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
5
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. UNIT - IV Java Strings Pardeep Sharma pardeepsharma727@gmail.com
  • 2. String class • are basically immutable objects in Java. • Immutable means once created, the strings cannot be changed. • Whenever we create strings, it is this class that is instantiated. • In Java strings can be instantiated in two ways: – String str= “You Cannot Change me”; – String str2=new String (“You Cannot Change me”);
  • 3. Java.lang.String • • • • • To create an empty string String str1=new String(); String str2=“You cannot ”+ “Change me”; Char ch[]={‘a’ , ’b’ , ’c’}; String str3=new String(ch); OUTPUT(abc)
  • 4. Common methods of the String class
  • 5. Methods of String class
  • 6. StringBuffer • StringBuffer is the class used for representing changing strings. • StringBuffer offers more performance enhancement whenever we change Strings, because it is this class that is actually used behind the curtain. • Just like any other buffer, StringBuffer also has a capacity and if the capacity is exceeded, then it is automatically made larger. • The initial capacity of StringBuffer can be known by using a method capacity().
  • 7. StringBuffer Constructors
  • 8. Length(); capacity();
  • 9. Thanks