Hungarian Notation for Java

Hungarian notation is used in naming variables and data types. It allows a programmer to quickly see what type of data is being used in a section of code. It has the additional benefit of preventing name clashes between variables, types, and the Java reserved words.

 

Type Specificiers


  • A — Abstract

    Used for abstract classes.

    abstract class CAMyAbstractClass {
        // class definition
    }
    
  • C — Class

    Used for any class.

    class CMyClass {
        // class definition
    }
    
  • E — Enumeration

    Used for enumerations.

    enum EMyEnumeration {keValue1, keValue2}
    
  • F — Final Class

    Used for final classes that cannot be inherited.

    final class CFMyFinalClass {
        // class definition
    }
    
  • I — Interface

    Used for intefaces.

    interface IMyInterface
        // inteface definition
    }
    
  • P — Package

    Used for packages

    package PMyPackage;
    

Type Identifiers


  • a — array

    Used for array data

    int iaIntArray = new int[5];
    
  • b — boolean

    Used for boolean data

    boolean  bIsDone = false;
    
  • c — char

    Used for character data

    char cMyChar = 'a';
    
  • d — double

    Used for double data

    double dMyDouble = 2.4;
    
  • e — enumerated type

    Used for enumerated data

    EMyEnumType eEnumInstance;
    
  • f — float

    Used for float data

    Float fMyFloat = 6.2;
    
  • i — int

    Used for int data

    int iMyInteger = 3;
    
  • k — final (constant)

    Used for constant data

    final double kdConstDouble = 5.0;
    
  • l — long

    Used for long data

    long lMyLong = 4;
    
  • m — member

    Used for member data

    class CMyClass {
        int miMemberInteger;
    }
    
  • q — unknown programmer-defined type

    Used for unknown type data

    CPoint qMyPoint;
    
  • s — short

    Used for short data

    short sMyShort = 4;
    
  • t — type (class)

    Used for class data

    class CMyClass {
        static int tiClassInt;
    }
    
  • y — byte

    Used for byte data

    byte yMyByte = 10;