Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1.  
  2. package zad7;
  3.  
  4.  
  5. public class Zad7 {
  6.  
  7. public class Zewnetrzna
  8. {
  9. private int a;
  10.  
  11. public int getA() {
  12. return a;
  13. }
  14. private void metoda()
  15. {
  16. System.out.println("zewnatrz");
  17. }
  18. public void suma()
  19. {
  20. //metoda2(); tu widac ze nie mozemy korzystac z metod wewnetrznej klasy
  21. }
  22. public class Wewnetrzna
  23. {
  24. private int b;
  25. public void metoda2()
  26. {
  27. int zmienna=a+b;
  28. System.out.println("a+b= "+zmienna);
  29. metoda();
  30. }
  31.  
  32. public int getB() {
  33. return b;
  34. }
  35.  
  36. }
  37. }
  38.  
  39.  
  40. public static void main(String[] args) {
  41. Zewnetrzna z=new Zewnetrzna();
  42. Zewnetrzna.Wewnetrzna w=z.new Wewnetrzna();
  43. z.a=10;
  44. z.metoda();
  45.  
  46. }
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement