-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package ru.j4j.oop; | ||
|
||
public class Calc { | ||
|
||
public static class Multiple { | ||
|
||
private final int rsl; | ||
|
||
public Multiple(int number) { | ||
rsl = number; | ||
} | ||
|
||
public int getResult() { | ||
return rsl; | ||
} | ||
|
||
} | ||
|
||
public static Multiple getMult(int value) { | ||
int result = value * value; | ||
return new Multiple(result); | ||
} | ||
|
||
public static void main(String[] args) { | ||
Calc.Multiple mult = Calc.getMult(3); | ||
System.out.println("Квадрат числа равен " + mult.getResult()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package ru.j4j.oop; | ||
|
||
public class StNested { | ||
|
||
private static int num1; | ||
public int num2; | ||
|
||
public StNested() { | ||
} | ||
|
||
static class StaticNested { | ||
|
||
void setStaticOuterVariable(int value) { | ||
num1 = value; | ||
} | ||
|
||
} | ||
|
||
public static void main(String[] args) { | ||
num1 = 1; | ||
StaticNested nested = new StaticNested(); | ||
nested.setStaticOuterVariable(2); | ||
System.out.println("num1 = " + num1); | ||
} | ||
} |