Constant « Class « Java Articles

Java Articles
1. Build Deploy
2. Class
3. Core Library
4. Data Types
5. Database JDBC
6. Design
7. Development
8. File Input Output
9. Graphics Desktop
10. J2EE Enterprise
11. J2ME Wireless
12. JVM
13. Language
14. Library Product
15. Network
16. Security
17. SOA Web Services
18. Test
19. Web Development
20. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Products
Java by API
Photoshop Tutorial
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Articles » Class » Constant 
1. Create enumerated constants in Java
"Using enumerated constants can make code more readable. For example, you might want to define a new data type named Color with constants RED, GREEN, and BLUE as its possible values. The idea is to have Color as an attribute of other objects you create, such as Car objects:"

2. When a constant isn't really a constant
"Note that for constant inlining to happen, several conditions must take place simultaneously. For example, it won't occur if the field initializer expression can be evaluated only at runtime:"

3. Use constant types for safer and cleaner code
"This month's tool is a variation on a theme. I will be expanding on the idea of enumerated constants as covered in Eric Armstrong's July 1997 JavaWorld article, "Create enumerated constants in Java." I strongly recommend reading that article before you immerse yourself in this one, as I will assume that you are familiar with the concepts related to enumerated constants, and I will expand on some of the example code which Eric presented."

4. Constants
"Lately, I've been doing a lot of XML parsing. Before I start writing a parser, I declare an interface that contains a constant for each tag name and attribute. Declaring each tag name allows me to change the markup language without altering my parsing code -- I can simply update the constants."

5. Constants, I do declare
"n "Constants" (JavaWorld, March 30, 2001), I wrote, "I'd be interested to hear how others declare their constants and why. I can post your responses in a future Q&A." Well, here are some reader responses."

ww_w.__j_a__v___a___2___s___._c___om___ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.