Results 1 to 2 of 2

Thread: Enumerations

  1. #1
    allaudin's Avatar
    allaudin is offline Senior Member
    Join Date
    Apr 2013
    Rep Power

    Default Enumerations

    Java Code:
    enum Bool {
    		TRUE(1), FALSE(0);
    		private int value;
    		private Bool(int value) {
    			this.value = value;
    		int getValue() {
    			return value;
    public static void main(String[] args){
    System.out.println(Bool.TRUE.getValue());      // HOW IT WORKS ???
    can do it by Bool b = Bool.TRUE; System.out.println(b.getValue()); Is the above line creates bool object automatically ?
    Last edited by allaudin; 08-03-2013 at 03:58 PM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

    Default Re: Enumerations

    Enum constants are static; they are created when the class is loaded.

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Ho to work with enumerations in java
    By zizou147 in forum Advanced Java
    Replies: 0
    Last Post: 03-22-2008, 01:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts