BAEL-2472 changes after editor-review

This commit is contained in:
jose 2019-01-13 15:12:40 -03:00
parent 065a6e2519
commit 9c0363e221
6 changed files with 23 additions and 28 deletions

View File

@ -0,0 +1,14 @@
package org.baeldung.variable.scope.examples;
public class BracketScopeExample {
public void mathOperationExample() {
Integer sum = 0;
{
Integer number = 2;
sum = sum + number;
}
// compiler error, number cannot be solved as a variable
// number++;
}
}

View File

@ -9,7 +9,6 @@ public class ClassScopeExample {
}
public void anotherExampleMethod() {
amount--;
Integer anotherAmount = amount + 4;
}
}
}

View File

@ -12,7 +12,7 @@ public class LoopScopeExample {
for (String name : listOfNames) {
allNames = allNames + " " + name;
}
// compiler error, name cannot be resolved to a variable
// String lastNameUsed = name;
}
}
}

View File

@ -2,15 +2,12 @@ package org.baeldung.variable.scope.examples;
public class MethodScopeExample {
Integer size = 2;
public void methodA() {
Integer area = 2;
area = area + size;
}
public void methodB() {
size = size + 5;
// compiler error, area cannot be resolved to a variable
// area = area + 2;
}
}
}

View File

@ -9,5 +9,4 @@ public class NestedScopesExample {
String title = "John Doe";
System.out.println(title);
}
}
}

View File

@ -1,14 +0,0 @@
package org.baeldung.variable.scope.examples;
public class OutOfScopeExample {
public void methodWithAVariableDeclaredInside() {
String name = "John Doe";
System.out.println(name);
}
public void methodWithoutVariables() {
System.out.println("Pattrick");
}
}