-
Recent Posts
Recent Comments
- Brian on How to plot multiple UK addresses (by postcode) on a Google Map
- Mark on How to plot multiple UK addresses (by postcode) on a Google Map
- Mark on How to plot multiple UK addresses (by postcode) on a Google Map
- Brian on Interview advice for PGCE ICT with Computing at KCL / IOE
- Brian on Blatant racist discrimination in advertisements
Tag Cloud
abstract accommodation array bursary Chrome date email enumerated type exam Excel fields finance generics Google greenfoot GTP GTTR hardware ICT interview Java KCL laptop linux literature review LMC London network news object OOP Oracle PGCE primary programming QTS QTS tests SER shortcut SSA static travel ubuntu UML variablesArchives
Categories
Meta
Tag Archives: enumerated type
Constant-specific class body (Java enum)
Consider the following example which defines an enum type with three constant values. The next–and admittedly somewhat contrived–example calls a constructor to associate an integer value with each enum constant. But how about if we wanted to override getNum() for … Continue reading
Public enum type with constructor, instance variable, and public method
This example program has two source files (Demo.java and Bucket.java) and demonstrates use of an enum type with a constructor, instance variable, and public method. Demonstration class:
How to overload an enum constructor
The following example shows a Java enum type in its simplest form. To associate a Celsius value with each enum value, we could do this: The above example uses a constructor with a single argument, but the following example shows how we … Continue reading
Java enum types to represent card rank and suit
Here’s my solution to write a Card and Deck class using Java enumerated types (enum type) to represent the suit and rank of each card. Funnily enough, I had more problems remembering the names of the suits and ranks than … Continue reading
Java enum types and the values() method
The Java compiler adds special methods to an enum type when it is created, one example of which is the values method. This is a static method that returns an array of all values declared in an enum type. The … Continue reading
Java programming: a simple example using the enum type
In Java, the enum declaration declares a class called an enum type. The following code shows a very simple enum type for days of the week. We cannot instantiate an enum type directly, but we can create variables of that … Continue reading