Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
U
Uebung09Zeichenketten
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlfaTrainingKurse
Java
Uebung09Zeichenketten
Commits
bc2470dc
Commit
bc2470dc
authored
5 years ago
by
Dennis Eisold
Browse files
Options
Downloads
Patches
Plain Diff
Initial commit
parents
No related branches found
No related tags found
No related merge requests found
Pipeline
#116
failed with stages
in 18 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Uebung09Zeichenketten.iml
+12
-0
12 additions, 0 deletions
Uebung09Zeichenketten.iml
src/de/itstall/Main.java
+125
-0
125 additions, 0 deletions
src/de/itstall/Main.java
with
137 additions
and
0 deletions
Uebung09Zeichenketten.iml
0 → 100755
+
12
−
0
View file @
bc2470dc
<?xml version="1.0" encoding="UTF-8"?>
<module
type=
"JAVA_MODULE"
version=
"4"
>
<component
name=
"NewModuleRootManager"
inherit-compiler-output=
"true"
>
<exclude-output
/>
<content
url=
"file://$MODULE_DIR$"
>
<sourceFolder
url=
"file://$MODULE_DIR$/src"
isTestSource=
"false"
/>
</content>
<orderEntry
type=
"inheritedJdk"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
</component>
</module>
This diff is collapsed.
Click to expand it.
src/de/itstall/Main.java
0 → 100755
+
125
−
0
View file @
bc2470dc
package
de.itstall
;
public
class
Main
{
public
static
void
main
(
String
[]
args
)
{
String
strText
=
" Mein23 Text23423411 "
;
System
.
out
.
println
(
"digitCount:\t\t\t"
+
digitCount
(
strText
));
System
.
out
.
println
(
"stringReverse:\t\t|"
+
stringReverse
(
strText
)
+
"|"
);
System
.
out
.
println
(
"lTrim:\t\t\t\t|"
+
lTrim
(
strText
)
+
"|"
);
System
.
out
.
println
(
"rTrim:\t\t\t\t|"
+
rTrim
(
strText
)
+
"|"
);
System
.
out
.
println
(
"trim:\t\t\t\t|"
+
trim
(
strText
)
+
"|"
);
System
.
out
.
println
(
"subStringCount:\t\t"
+
subStringCount
(
strText
,
"2"
));
}
/**
* Counts digits in strText
* @param strText : String
* @return int
*/
public
static
int
digitCount
(
String
strText
)
{
int
iReturn
=
0
;
for
(
int
i
=
0
;
i
<
strText
.
length
();
i
++)
{
char
c
=
strText
.
charAt
(
i
);
if
(
c
<
'0'
||
c
>
'9'
)
continue
;
iReturn
++;
}
return
iReturn
;
}
/**
* Reverses a String
* @param strText : String : Text to reverse
* @return String
*/
public
static
String
stringReverse
(
String
strText
)
{
String
strReturn
=
""
;
char
[]
cText
=
strText
.
toCharArray
();
for
(
int
i
=
cText
.
length
-
1
;
i
>=
0
;
i
--)
{
strReturn
+=
String
.
valueOf
(
cText
[
i
]);
}
return
strReturn
;
}
/**
* Removes leading spaces
* @param strText : String
* @return String
*/
public
static
String
lTrim
(
String
strText
)
{
String
strReturn
=
""
;
int
iTemp
=
0
;
char
[]
cText
=
strText
.
toCharArray
();
boolean
checkForWhitespace
=
true
;
for
(
char
i
:
cText
)
{
if
(
Character
.
isWhitespace
(
i
)
&&
checkForWhitespace
)
{
iTemp
++;
}
else
{
checkForWhitespace
=
false
;
strReturn
+=
String
.
valueOf
(
i
);
}
}
return
strReturn
;
}
/**
* Removes last spaces
* @param strText : String
* @return String
*/
public
static
String
rTrim
(
String
strText
)
{
String
strReturn
=
""
;
int
iFounds
=
0
;
char
[]
cText
=
strText
.
toCharArray
();
boolean
checkForWhitespace
=
true
;
for
(
int
i
=
cText
.
length
;
i
>
0
;
i
--)
{
if
(
Character
.
isWhitespace
(
cText
[(
cText
.
length
-
i
)])
&&
checkForWhitespace
)
{
iFounds
++;
}
else
{
checkForWhitespace
=
false
;
}
}
strReturn
=
strText
.
substring
(
0
,
strText
.
length
()
-
iFounds
);
return
strReturn
;
}
/**
* removes leading and last spaces
* @param strText : String
* @return String
*/
public
static
String
trim
(
String
strText
)
{
String
strReturn
=
""
;
strReturn
=
rTrim
(
strText
);
strReturn
=
lTrim
(
strReturn
);
return
strReturn
;
}
/**
* Counts search in given String
* @param strText
* @return
*/
public
static
int
subStringCount
(
String
strText
,
String
strSearch
)
{
int
iReturn
=
0
;
if
(
0
!=
strSearch
.
length
())
{
for
(
int
i
=
strText
.
indexOf
(
strSearch
,
0
);
i
!=
-
1
;
i
=
strText
.
indexOf
(
strSearch
,
i
+
1
))
{
iReturn
++;
}
}
return
iReturn
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment