Java
  Home arrow Java arrow Page 4 - Java and Object-Oriented Programming
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
JAVA

Java and Object-Oriented Programming
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 9
    2007-09-19


    Table of Contents:
  • Java and Object-Oriented Programming
  • How State and Behavior Affect One Another
  • Class, Inheritance and Interface
  • All About Variables

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Java and Object-Oriented Programming - All About Variables
    ( Page 4 of 4 )

    Variables

    Since we spoke about variables or fields in the Object portion of our tutorial, we'll cover them more in depth here. Java allows for four types of variables. They are as follows:

    Instance Variables are used for storing the individual states of an object.

    Class Variable is a single variable that used for all of the objects within a class.

    Local Variables are used to store temporary states of an object. A local variable is used only within a method and is not usable outside of where it was declared.

    Parameters are always variables, and never fields.

    Variable Naming Conventions

    Just as you can't run around calling everyone "Hey you!" (well you could, but good luck finding the right Hey You in your phone book), you can't simply tell your computer to use "that variable over there with the funny haircut." Below is a list of rules for naming variables.

    1. Names may consist of letters, numbers, dollar signs, and underscores.

    2. It is better to use the full word when naming variables to avoid confusion later on. For instance instead of naming a button b_g, take the time to spell out bubble_gum. When you get a call at three o'clock in the morning because your program isn't working, you'll thank yourself.

    3. To make the names more readable, if it contains two words, always uppercase the first letter of each word. If it is one word, keep it lowercase. (Example: BubbleGum or bubble). And remember: no spaces.

    4. Variable names are case-sensitive. If you name your variable bubble and refer to it later as Bubble, it will not work.

    In the next tutorial on Programming in Java, we will discuss the Data Types of variables (certain variables hold certain types of data) and cover more of the basic language rules.



     
     
    >>> More Java Articles          >>> More By James Payne
     

       

    JAVA ARTICLES

    - Exception Handling Techniques in Java
    - More About Multithreading in Java
    - The Basics of Multiple Threads in Java
    - Data Access Using Spring Framework JDBC
    - New Object Initialization in Java
    - Adding Images With iTextSharp
    - Adding Columns With iTextSharp
    - Creating Simple PDF Files With iTextSharp
    - The Spring Framework: Understanding IoC
    - Introducing the Spring Framework
    - Java Classes
    - Completing the Syntactic Comparison of Java ...
    - Syntactic Comparison of Java and C/C++
    - Java Statements
    - Conditionals, Expressions and Other Java Ope...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek