Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package zad7;
- public class Zad7 {
- public class Zewnetrzna
- {
- private int a;
- public int getA() {
- return a;
- }
- private void metoda()
- {
- System.out.println("zewnatrz");
- }
- public void suma()
- {
- //metoda2(); tu widac ze nie mozemy korzystac z metod wewnetrznej klasy
- }
- public class Wewnetrzna
- {
- private int b;
- public void metoda2()
- {
- int zmienna=a+b;
- System.out.println("a+b= "+zmienna);
- metoda();
- }
- public int getB() {
- return b;
- }
- }
- }
- public static void main(String[] args) {
- Zewnetrzna z=new Zewnetrzna();
- Zewnetrzna.Wewnetrzna w=z.new Wewnetrzna();
- z.a=10;
- z.metoda();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement