Created
November 21, 2018 00:20
-
-
Save fahmifan/7c731efe916e3d3ee5e2cf1118a61f5a to your computer and use it in GitHub Desktop.
example use of Enumeration type in java language
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Vector; | |
import java.util.Enumeration; | |
import java.util.ArrayList; | |
import java.util.List; | |
public class TryEnumeration { | |
public static void main(String args[]) { | |
// Enumeration accept Type T, it called Generics | |
Enumeration<String> days; | |
// Vector accept Type T, it called Generics | |
Vector<String> dayNames = new Vector<String>(); | |
dayNames.add("Sunday"); | |
dayNames.add("Monday"); | |
dayNames.add("Tuesday"); | |
dayNames.add("Wednesday"); | |
dayNames.add("Thursday"); | |
dayNames.add("Friday"); | |
dayNames.add("Saturday"); | |
days = dayNames.elements(); | |
while (days.hasMoreElements ()) { | |
System .out.println(days.nextElement()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment