FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
java-coding-ninjas/strings/StringBasics.java at master · avinashbest/java-coding-ninjas · GitHub
avinashbest
/
java-coding-ninjas
Public
Notifications
You must be signed in to change notification settings
Fork
11
Star
18
Code
Issues
0
Pull requests
2
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-coding-ninjas
/
strings
/
StringBasics.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
35 lines (31 loc) · 1.16 KB
Breadcrumbs
java-coding-ninjas
/
strings
/
StringBasics.java
Copy path
File metadata and controls
35 lines (31 loc) · 1.16 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
package
strings
;
public
class
StringBasics
{
public
static
void
main
(
String
[]
args
) {
char
[]
arr
= {
'C'
,
'o'
,
'd'
,
'i'
,
'n'
,
'g'
};
String
str1
=
"Coding"
;
String
str2
=
" is fun"
;
String
str3
=
"Ceding"
;
System
.
out
.
println
(
str1
);
/*length of the string*/
System
.
out
.
println
(
str1
.
length
());
/*character at a particular index*/
System
.
out
.
println
(
str1
.
charAt
(
4
));
/*Concatenating Strings*/
str1
+=
str2
;
str1
=
str1
.
concat
(
str2
);
/*1st string contains 2nd string*/
System
.
out
.
println
(
str1
.
contains
(
"ing"
));
/*Equal String or not?*/
System
.
out
.
println
(
str1
.
equals
(
str3
));
/*compare string lexicographically*/
System
.
out
.
println
(
str1
.
compareTo
(
str3
));
/*String Substring Function*/
System
.
out
.
println
(
str1
.
substring
(
0
));
System
.
out
.
println
(
str1
.
substring
(
1
));
System
.
out
.
println
(
str1
.
substring
(
2
));
System
.
out
.
println
(
str1
.
substring
(
3
));
System
.
out
.
println
(
str1
.
substring
(
4
));
System
.
out
.
println
(
str1
.
substring
(
5
));
System
.
out
.
println
(
str1
.
substring
(
6
));
}
}
Back
|
FazBrowse Home
|
New Git URL