D
D
Dmitry2021-02-12 21:03:58
Java
Dmitry, 2021-02-12 21:03:58

How to increase one variable depending on another?

I understand that the question is stupid and it is quite possible that I will understand how to do it with a fresh mind in the morning, but unfortunately I need it right now.

There are two variables:

int simbol_lenght = 0;
int count_simbol_up = 0;


simbol_lenghtduring operation, it can take any value from 0 and above. count_simbol_upHow can I make it increase by +1 every time the value of this variable is greater than 2 ?

I understand that the question is simple, but the brain no longer thinks.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Roo, 2021-02-12
@xez

class BindedInts {
int symbolLenght;
int countSymbolUp;

Integer getCountSymbolUp() {
   return this.symbolLenght > 2 ? this.symbolLenght+1 : this.countSymbolUp;
}
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question