100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

Test (elaborations) Computer programming

Rating
-
Sold
-
Pages
5
Grade
A+
Uploaded on
22-04-2025
Written in
2024/2025

Perfect for examination preparation , it includes multiple questions for revision.

Institution
Senior / 12th Grade
Course
Computer programming









Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Senior / 12th grade
Course
Computer programming
School year
4

Document information

Uploaded on
April 22, 2025
Number of pages
5
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

STRINGBUFFER DATA TYPE
You can declare an object of StringBuffer type. This creates reasonable space in the mem
called Buffer to contain a string. The following statements are used to create StringBu2
objects:
" StringBuffer m=new StringBuffer( );
This allocates an empty space in the memory to store a string.
" StringBuffer m=new StringBuffer("COMPUTER");
The above statement allocates memory for variable m and initialises it with su
"COMPUTER".
"StringBuffer m=new StringBuffer(25); maximum
The above statement allocates memory space for storing astring up to a
25 characters.
characteristo
Once an Object is created as possesses the following
StringBuffer
() It refers to as a specific length in type, it po
(ii) The length can be memorv to contain characters. Programmersbyus
SetLength( ) function.changed according to the need of the charate
(ii) If a string has bigger object, then the
length than the size of
exceeding the size are
(i0) If a string is truncated. StringButter contains
smaller than the size of the then it
characters (\u0000) in the empty
space.
StringButfer object,

, sIringBufferFunctions
Therearesonme functions especially used on the StringBuffer object. These functions are
discussedbelow:

Append(
)
Thisfunction is used to add a string at the end of another string.
$yntax: StringBuffer variable1.append(StringBuffer variable2);
Forexample,
rBuffer k =new StringBuffer("COMPUTER"):
StringBufter p= new StringBufer("APPLICATIONS");
kappend(p):
the value for 'k' as COMPUTERAPPLICATIONS.
Itreturns
Note: You must keep in your mind that a StringBuffer function doesn't use extra variable for
storingthe result. The change is saved in the current object through which the function is
called.




setCharAt()
specified index.
This function can be used toreplace a character with another character at
Character):
Syntax: StringBuffer variable.setCharAt(Index,
For example,
StringBuffer s=new StringBuffer("COMMUTER");
S.setCharAt(3, 'P');
It will return the value for s as COMPUTER.

insert()
specified index into another string.
Ihis function allows you to insert a string at a
variable2);
Syntax: StringBuffer variablel.insert(index, StringBuffer
For example,
DtingBuffer s=new StringBuffer("COMPUTER FUN");
DUngBuffer p=new StringBuffer(" 1S;
sinsert(8, p): IS FUN.
It will return the value for s as COMPUTER

delete()
This function is used to deletethe characters from one index to another index of
a string.

variable.delete(index1, index2);
Synt a x: : StringBuffer thanindex2
index2 would mean atleast 1 position less
Here,
For example,
StringBuffer S=neW StringBuffer("COMPUTER");
from
characters positioned
s.Itdelwielte(3,return5); the value for S as COMTER,
as it removesthe

hdex 3 to index
(5-1).
R163,81
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
tisyaverma

Get to know the seller

Seller avatar
tisyaverma Physics wallah
Follow You need to be logged in order to follow users or courses
Sold
0
Member since
8 months
Number of followers
0
Documents
13
Last sold
-

0,0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can immediately select a different document that better matches what you need.

Pay how you prefer, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card or EFT and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions