當前位置:編程學習大全網 - 網站源碼 - JAVA編寫壹個完整的計數器類Count,寫出源代碼

JAVA編寫壹個完整的計數器類Count,寫出源代碼

public class Count{ int countValue; Count(){ countValue=0; } public void increment() { countValue++; } public void decrement() { countValue--; } public void reset() { countValue=0; } public int getCountValue(){ return countValue; } public static void main(String args[]){ Count c = new Count(); c.increment(); System.out.println(c.getCountValue()); c.reset(); System.out.println(c.getCountValue()); } } 運行結果: 1 0

采納哦

  • 上一篇:自動發卡平臺支付通道怎麽弄的
  • 下一篇:如何為Tik Tok的餐館做團購?
  • copyright 2024編程學習大全網