Moving classes into core-java-lang
This commit is contained in:
parent
b019fb6701
commit
4c540b764c
@ -1,14 +0,0 @@
|
|||||||
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++;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
package org.baeldung.variable.scope.examples;
|
|
||||||
|
|
||||||
public class ClassScopeExample {
|
|
||||||
|
|
||||||
Integer amount = 0;
|
|
||||||
|
|
||||||
public void exampleMethod() {
|
|
||||||
amount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void anotherExampleMethod() {
|
|
||||||
Integer anotherAmount = amount + 4;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
package org.baeldung.variable.scope.examples;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class LoopScopeExample {
|
|
||||||
|
|
||||||
List<String> listOfNames = Arrays.asList("Joe", "Susan", "Pattrick");
|
|
||||||
|
|
||||||
public void iterationOfNames() {
|
|
||||||
String allNames = "";
|
|
||||||
for (String name : listOfNames) {
|
|
||||||
allNames = allNames + " " + name;
|
|
||||||
}
|
|
||||||
// compiler error, name cannot be resolved to a variable
|
|
||||||
// String lastNameUsed = name;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
package org.baeldung.variable.scope.examples;
|
|
||||||
|
|
||||||
public class MethodScopeExample {
|
|
||||||
|
|
||||||
public void methodA() {
|
|
||||||
Integer area = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void methodB() {
|
|
||||||
// compiler error, area cannot be resolved to a variable
|
|
||||||
// area = area + 2;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
package org.baeldung.variable.scope.examples;
|
|
||||||
|
|
||||||
public class NestedScopesExample {
|
|
||||||
|
|
||||||
String title = "Baeldung";
|
|
||||||
|
|
||||||
public void printTitle() {
|
|
||||||
System.out.println(title);
|
|
||||||
String title = "John Doe";
|
|
||||||
System.out.println(title);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user