FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java/07-Java-Programs/078-String-Length.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
/
078-String-Length.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
55 lines (44 loc) · 1.64 KB
Breadcrumbs
Java
/
07-Java-Programs
/
078-String-Length.java
Copy path
File metadata and controls
55 lines (44 loc) · 1.64 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
/*
* ============================================================================
* Program Name : String Length
* File Name : 078-String-Length.java
* Class Name : StringLength
*
* Description:
* This program accepts a String from the user and finds its length
* using the length() method of the String class.
*
* Objective:
* - Understand how to read a String from the user.
* - Learn how to use the length() method.
* - Display the total number of characters in a String.
*
* Author : Shaik Mahaboob Basha
* Repository : 01-Core-Java
* Folder : 08-Java-Programs
* ============================================================================
*/
import
java
.
util
.
Scanner
;
public
class
StringLength
{
// The main() method is the entry point of every Java application.
public
static
void
main
(
String
[]
args
) {
// Create a Scanner object to read input from the keyboard.
Scanner
scanner
=
new
Scanner
(
System
.
in
);
// Ask the user to enter a string.
System
.
out
.
print
(
"Enter a String: "
);
// Read the complete string entered by the user.
String
text
=
scanner
.
nextLine
();
// Find the length of the string.
int
length
=
text
.
length
();
// Display the entered string.
System
.
out
.
println
(
"Entered String: "
+
text
);
// Display the length of the string.
System
.
out
.
println
(
"Length of the String: "
+
length
);
// Example Output:
// Enter a String: Core Java
// Entered String: Core Java
// Length of the String: 9
// Close the Scanner object to release system resources.
scanner
.
close
();
}
}
Back
|
FazBrowse Home
|
New Git URL