Enum Example- Java
-
Upload
shashank-srivastava -
Category
Documents
-
view
223 -
download
0
description
This file illustrates use of a java enum in practical scenarios.
Transcript of Enum Example- Java
-
Java enum example:
Below enum defines different types of dialog types.
public enum CustomerDialogType {
ADD_DIALOG("ADD ADDRESS"), EDIT_DIALOG("EDIT ADDRESS"), NEW_CUSTOMER("NEW CUSTOMER");
private String title;
private CustomerDialogType(String title) { this.title = title; }
public String getTitle() { return title; } } Very simple enum class describing different types of dialogs possible in an application. Instead of using hard-coded strings this can be made use of to name a dialog.