FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java/07-Java-Programs/090-StringBuffer-Example.java at main · shaikbasha-dev/Java · GitHub
shaikbasha-dev
/
Java
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Java
/
07-Java-Programs
/
090-StringBuffer-Example.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
62 lines (52 loc) · 2.25 KB
Breadcrumbs
Java
/
07-Java-Programs
/
090-StringBuffer-Example.java
Copy path
File metadata and controls
62 lines (52 loc) · 2.25 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* ============================================================================
* Program Name : StringBuffer Example
* File Name : 090-StringBuffer-Example.java
* Class Name : StringBufferExample
*
* Description:
* This program demonstrates the usage of the StringBuffer class.
* It performs various operations such as append, insert, replace,
* delete, reverse, and displays the modified StringBuffer.
*
* Objective:
* - Understand the concept of StringBuffer.
* - Learn how to modify strings using StringBuffer methods.
* - Understand that StringBuffer objects are mutable.
*
* Author : Shaik Mahaboob Basha
* Repository : 01-Core-Java
* Folder : 08-Java-Programs
* ============================================================================
*/
public
class
StringBufferExample
{
// The main() method is the entry point of every Java application.
public
static
void
main
(
String
[]
args
) {
// Create a StringBuffer object.
StringBuffer
stringBuffer
=
new
StringBuffer
(
"Java"
);
// Display the original StringBuffer.
System
.
out
.
println
(
"Original StringBuffer : "
+
stringBuffer
);
// Append text to the StringBuffer.
stringBuffer
.
append
(
" Programming"
);
System
.
out
.
println
(
"After append() : "
+
stringBuffer
);
// Insert text at the specified index.
stringBuffer
.
insert
(
5
,
"Core "
);
System
.
out
.
println
(
"After insert() : "
+
stringBuffer
);
// Replace characters from index 5 to 9.
stringBuffer
.
replace
(
5
,
9
,
"Advanced "
);
System
.
out
.
println
(
"After replace() : "
+
stringBuffer
);
// Delete characters from index 5 to 14.
stringBuffer
.
delete
(
5
,
14
);
System
.
out
.
println
(
"After delete() : "
+
stringBuffer
);
// Reverse the StringBuffer.
stringBuffer
.
reverse
();
System
.
out
.
println
(
"After reverse() : "
+
stringBuffer
);
// Example Output:
// Original StringBuffer : Java
// After append() : Java Programming
// After insert() : Java Core Programming
// After replace() : Java Advanced Programming
// After delete() : Java Programming
// After reverse() : gnimmargorP avaJ
}
}
Back
|
FazBrowse Home
|
New Git URL