Java – if (pause = = null) {does not work
•
Java
When pause is null, I use if (pause = = null) to perform some operations But I made a mistake
For parameter type long, null, operator = = undefined
This is the code,
public class Timer extends CountDownTimer { long pause = (Long) null; public Timer(long startTime,long interval) { super(startTime,interval); } @Override public void onTick(long millisUntilFinished) { content.setText("Tijd over: " + millisUntilFinished / 100); } public void onPause(long millisUntilFinished) { if(pause == null) { pause = millisUntilFinished; content.setText("Tijd over: " + millisUntilFinished / 100); this.cancel(); } else { this.start(); } } @Override public void onFinish() { content.setText("Tijd is op!"); } }
This class is not yet complete, so ignore the rest of the code
Solution
The variable pause is very long, so the pause will never be null, and the compiler will be confused Either make it long or use some invalid in band indication
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码