About 7,560,000 results
Open links in new tab
  1. How to declare a constant in Java? - Stack Overflow

    Oct 9, 2012 · We always write: public static final int A = 0; Question: Is static final the only way to declare a constant in a class? If I write public final int A = 0; instead, is A still a constant or...

  2. Why is there no Constant feature in Java? - Stack Overflow

    Mar 7, 2016 · Interestingly, the Java language specification regards const as a reserved keyword — i.e., one that cannot be used as variable identifier — but assigns no semantics to it. It is …

  3. java - whats the purpose of "const" keyword? - Stack Overflow

    May 31, 2012 · Why const is a reserved keyword in Java but has no function? If they decided to use final instead then whats the point of having const?

  4. What is the best way to implement constants in Java?

    Sep 16, 2008 · What is the best way to implement constants in Java? One approach that we should really avoid : using interfaces to define constants. Creating a interface specifically to …

  5. Equivalent of const(C++) in Java - Stack Overflow

    Oct 25, 2011 · A final class is not a const class but a sealed class that cannot be inherited. A final method is a sealed method, a method that cannot be overridden. In C++ there is the concept …

  6. Why const keyword is not used in Java? - Stack Overflow

    Sep 15, 2011 · Possible Duplicate: Why is there no Constant keyword in Java? Why const keyword is not used in Java? Can you see any disadvantages of using some transitive const …

  7. How do you define a class of constants in Java? - Stack Overflow

    5 enum s are fine. IIRC, one item in effective Java (2nd Ed) has enum constants enumerating standard options implementing a [Java keyword] interface for any value. My preference is to …

  8. Defining constant string in Java? - Stack Overflow

    @csss final in Java means the reference can't be changed -- but the object it points to still might. Luckily for us, String in Java is an immutable class, so a final String is const in both regards.

  9. What is the Java equivalent of C++'s const member function?

    May 4, 2011 · In C++, I can define an accessor member function that returns the value of (or reference to) a private data member, such that the caller cannot modify that private data …

  10. why are java constants declared static? - Stack Overflow

    Why are Java constants declared static? class Foo { static final int FII = 2 ; } In this example I understand the use of final, But why does it have to be static? Why should it be a class vari...