标签:style blog io ar color 使用 sp on 数据
顾名思义,常量是其值在使用过程中不会发生变化的变量。在声明和初始化变量时,在变量的前面加上关键字const,就可以把该变量指定为一常量:
const tax=0.06;
常量具有以下特点:
class ConstTest
{
//下述的做法是错的 public double floatTax=0.06; const tax=floatTax;
//以下做法则是正确的
const int months = 12;
const int weeks = 52;
const int days = 365;
const double daysPerWeek = (double) days / (double) weeks;
const double daysPerMonth = (double) days / (double) months;
}
标签:style blog io ar color 使用 sp on 数据
原文地址:http://www.cnblogs.com/iloney/p/4150019.html