A constant looks like a variable, but the value behind the constant can't be changed. You assign a value to a constant that the compiler can resolve at compile time before executing your program. You can't set a constant equal to a function, because the result of the function would only be known when you execute the program. Constants can only be declared inside a class or inside a function. If declared inside a function, the constant can only be used inside that function. If declared in a class the constant can be used from anywhere (if marked as public). To define a constant:
Tips
|