How to add a new method called numberOfDigits() in java?

前端 未结 4 1031
面向向阳花
面向向阳花 2021-01-29 04:19

I have a program called public class ZeroCounter {. I want to add a new method to it called numberOfDigits() and add a line to test it in the main() method. How should I go abo

4条回答
  •  旧巷少年郎
    2021-01-29 04:58

    It should be:

    public class ZeroCounter {
    
        public static int numberOfDigits(int number) {
            //- Implementation goes here.
        }
    
        public static void main(String[] args) {
            int number;
            //- Initialize number variable.
            System.out.println("numberOfDigits(" + number + ")=" + numberOfDigits(number));
        }
    }
    

提交回复
热议问题