Skip to content

Commit 56c1e31

Browse files
Delayed Assignment: Fix variable declarations (#107)
Co-authored-by: Ethan McCue <[email protected]>
1 parent 9555b93 commit 56c1e31

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/standard_input_ii/delayed_assignment.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The problem with this is that Java isn't smart enough to know that you always in
1212
void main() {
1313
String name;
1414
while (true) {
15-
String name = IO.readln("What is your name? ");
15+
name = IO.readln("What is your name? ");
1616
if (name.isBlank()) {
1717
IO.println("Name cannot be blank!");
1818
continue;
@@ -31,7 +31,7 @@ To get around this you can either give an explicit default value.
3131
void main() {
3232
String name = null;
3333
while (true) {
34-
String name = IO.readln("What is your name? ");
34+
name = IO.readln("What is your name? ");
3535
if (name.isBlank()) {
3636
IO.println("Name cannot be blank!");
3737
continue;
@@ -52,7 +52,7 @@ to see that the code in the loop will run at least once.
5252
void main() {
5353
String name;
5454
do {
55-
String name = IO.readln("What is your name? ");
55+
name = IO.readln("What is your name? ");
5656
if (name.isBlank()) {
5757
IO.println("Name cannot be blank!");
5858
continue;

0 commit comments

Comments
 (0)