• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Java strings
 

Java strings

on

  • 137 views

Strings

Strings
StringBuffer
Difference between String and StringBuffer

Statistics

Views

Total Views
137
Views on SlideShare
137
Embed Views
0

Actions

Likes
0
Downloads
4
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Java strings Java strings Presentation Transcript

    • UNIT - IV Java Strings Pardeep Sharma pardeepsharma727@gmail.com
    • 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”);
    • 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)
    • Common methods of the String class
    • Methods of String class
    • 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().
    • StringBuffer Constructors
    • Length(); capacity();
    • Thanks