S
S
Sergey Sergey2021-05-10 22:27:27
Java
Sergey Sergey, 2021-05-10 22:27:27

How to apply the principle of encapsulation to this code?

class Fox {
    public static void main(String[] args) {
        int a = 1;
        int b = 2;
        int c = 3;
        int d = 4;
        for(a=1; a<4; a++){
         for(b=2; b<7; b++){
             for(c=3; c<10; c++){
              for(d=4; d<20; d++){
                  System.out.println("   " + a + b + c + d);
              }   
             }
         }   
        }
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Orkhan, 2021-05-10
@Sergei1111

There's not much to encapsulate, to be honest.
You have local variables inside the main() method, and there are a couple of loops that work with these variables.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question