is it even possible to add a 0 in java with terny operators?

前端 未结 3 1002
死守一世寂寞
死守一世寂寞 2021-01-29 11:16

Hi I\'ve tried everything from terny operators, if else statements and parsing the int to a string, I am making a clock that reads 4:01 4:02 but instead it outputs 4:1

t

3条回答
  •  长发绾君心
    2021-01-29 11:48

    The problem is this line:

    int blank = Integer.parseInt("0");
    

    Since your blank is an integer 0, blank + min will be the same as min. Try just using "0" without changing the type.

    Also, as David Wallace mentions, you should replace (min > 10 ) with (min >= 10 ) or (min > 9 )

提交回复
热议问题