Java
  Home arrow Java arrow Page 4 - Java Classes
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? 
JAVA

Java Classes
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 10
    2008-01-09


    Table of Contents:
  • Java Classes
  • How to Declare a Class
  • Using Public Methods to Obtain Private Fields
  • Naming Conventions for Our Pal, the Method
  • Creating Objects with Constructors

  • 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 Classes - Naming Conventions for Our Pal, the Method
    ( Page 4 of 5 )

    Methods can be named the same as classes. However, a bunch of nerds decided that they should all use the same convention, and that method names should be a lowercase verb, or if you want to add more than one word, then the second, third, and so forth words should have their first letter capitalized.

    Here are some examples of good method naming conventions:

      retrieveInfo

      killBoss

      eatChickenMcnuggets

      sleepAtWorkAndStillGetPaid

      dateAngelinaJolie

      watchMidgetWrestling

      slapMisterTThenRunLikeHell

    Most of the time methods will have a unique name. However, Java does allow for a little thing called overloading, which allows different methods to be named the same and yet still be distinguishable from one another due to method signatures. A method signature consists of its name and parameter types. An example of two methods with the same name and different signatures would be:


    killChuckNorris(int, int, int, double)

    killChuckNorris(double, double, double, int)


    Overloading is a little beyond the scope of this article, however we will discuss it in the future.

    Constructors: More than Meets the Eye

    Constructors can be thought of as big beluga construction workers, sitting on a fence and swinging their feet back and forth as they eat from a solid metal sandwich pail, cat-calling and generally going nuts when dames and broads with gams up to here walk by.

    Aside from belittling women and eating big sammiches, constructors also build objects based on blueprints that you provide. Who'da thunk you'd grow up to be a fancy-schmancy architect type?

    There are three types of constructors (unless you include copy, which we won't): default, non-default, and cloning. I'll describe each one briefly below:

    The Good Default Constructor

    Default constructors are typically used to create the most basic instance possible, which means giving all the members a value such as null or zero, or even an empty string. You can assign values, mind you, but typically you don't or some nerd will yell at you for being a bad programmer.

    The Bad Non-Default Constructor

    A non-default constructor is used to create an object with most of its values defined for all of the object's members. If your mother was an object, we could say that she is ugly, she is fat, she is easy, she loves the navy, and she votes Democratic.

    The Ugly Clone Constructor

    Settle down all you Star Wars nerds. I know the mere mention of the word Clone stirs you into a Clone Bores frenzy. Clone does what it probably sounds like: replicates an object.



     
     
    >>> 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 2 Hosted by Hostway
    Stay green...Green IT