Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
javaTutorial
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
lbr
javaTutorial
Commits
84839877
Commit
84839877
authored
2 years ago
by
lbr
Browse files
Options
Downloads
Patches
Plain Diff
ForLoop
parent
3829f829
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ForLoop/ForLoop/out/production/ForLoop/Main.class
+0
-0
0 additions, 0 deletions
ForLoop/ForLoop/out/production/ForLoop/Main.class
ForLoop/ForLoop/src/Main.java
+19
-13
19 additions, 13 deletions
ForLoop/ForLoop/src/Main.java
with
19 additions
and
13 deletions
ForLoop/ForLoop/out/production/ForLoop/Main.class
+
0
−
0
View file @
84839877
No preview for this file type
This diff is collapsed.
Click to expand it.
ForLoop/ForLoop/src/Main.java
+
19
−
13
View file @
84839877
public
static
class
Main
{
public
class
Main
{
public
static
boolean
main
(
int
number
){
public
static
void
main
(
String
[]
args
)
{
if
(
number
<
0
)
number
*=
-
1
;
System
.
out
.
println
(
sumFirstAndLastDigit
(
252
));
String
zahl
=
String
.
valueOf
(
number
);
System
.
out
.
println
(
sumFirstAndLastDigit
(
257
));
String
zahlRueckwaerts
=
new
StringBuilder
(
zahl
).
reverse
().
toString
();
System
.
out
.
println
(
sumFirstAndLastDigit
(
0
));
int
zahlInt
=
Integer
.
valueOf
(
zahl
);
System
.
out
.
println
(
sumFirstAndLastDigit
(
5
));
int
zahlRueckwaertsInt
=
Integer
.
valueOf
(
zahlRueckwaerts
);
System
.
out
.
println
(
sumFirstAndLastDigit
(-
10
));
if
(
zahlInt
==
zahlRueckwaertsInt
)
{
return
true
;
}
}
public
static
int
sumFirstAndLastDigit
(
int
number
)
{
else
{
if
(
number
<
0
)
return
-
1
;
return
false
;
String
numberAlsString
=
String
.
valueOf
(
number
);
}
char
ersterChar
=
numberAlsString
.
charAt
(
0
);
int
ersteZiffer
=
Character
.
getNumericValue
(
ersterChar
);
int
laengeVonNumberAlsString
=
numberAlsString
.
length
();
char
zweiterChar
=
numberAlsString
.
charAt
(
laengeVonNumberAlsString
-
1
);
int
letzteZiffer
=
Character
.
getNumericValue
(
zweiterChar
);
return
ersteZiffer
+
letzteZiffer
;
}
}
}
}
\ No newline at end of file
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