Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.vk.vitalypavlenko.newSandbox;
- public class MethodInnerClassTest {
- static Object someReference;
- public void Method(int z) {
- final int y = z;
- class Inner {
- int x;
- Inner(int x) {
- this.x = x;
- }
- public String toString() {
- return "hi, i'm Inner, my x is " + x +
- " and y in my method is " + y;
- }
- }
- if (someReference == null) {
- someReference = new Inner(42);
- } else {
- System.out.println((Inner) someReference);
- System.out.println("But actually y is " + y);
- }
- }
- public static void main(String[] args) {
- MethodInnerClassTest mict = new MethodInnerClassTest();
- mict.Method(1);
- mict.Method(2);
- someReference = null;
- mict.Method(3);
- mict.Method(4);
- }
- }
Add Comment
Please, Sign In to add comment