Advertisement
jaVer404

level15.lesson12.home08

Jul 18th, 2015
391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.15 KB | None | 0 0
  1. package com.javarush.test.level15.lesson12.home08;
  2.  
  3. /* Дебаг, дебаг, и еще раз дебаг
  4. Программа выводит 0 9, а должна 6 9. Найди одну! ошибку и исправь.
  5. Используй дебаг. Для этого поставь breakpoint-ы(Ctrl+F8), потом зайди в меню Run -> Debug.
  6. F9 - выполнение кода до следующего breakpoint-а
  7. F8 - переход к следующей строке кода
  8. */
  9.  
  10. public class Solution {
  11.     public static void main(String[] args) {
  12.         new B(6);
  13.     }
  14.  
  15.     public static class A {
  16.         private int f1 = 7;//6
  17.  
  18.         public A(int f1) {
  19.             this.f1 = f1;
  20.             initialize();
  21.         }
  22.  
  23.         private void initialize() {/*from protected to private*/
  24.             System.out.println(f1);
  25.         }
  26.     }
  27.  
  28.     public static class B extends A {
  29.         protected int f1 = 3;
  30.  
  31.         public B(int f1) {
  32.             super(f1);
  33.             this.f1 += f1;
  34.             initialize();
  35.         }
  36.  
  37.         protected void initialize() {
  38.             System.out.println(f1);
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement