/* * [TestHashSetInit.java] * * Summary: example use of java.util.HashSet initialisation. * * Copyright: (c) 2012-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.0 2012-05-08 initial version */ package com.mindprod.example; import java.util.Arrays; import java.util.HashSet; import static java.lang.System.*; /** * example use of java.util.HashSet initialisation. * * @author Roedy Green, Canadian Mind Products * @version 1.0 2012-05-08 initial version * @since 2012-05-08 */ public final class TestHashSetInit { /** * initial values for the HashSet */ private static final String[] REGIONS = { "WA", "NY", "RI", "BC", "ON" }; /** * Sample code to TEST and demonstrate the use of HashSet initialisation * * @param args not used */ public static void main( String[] args ) { // create a new HashSet containing a list of all the legitimate state // and province abbreviations. HashSet regions = new HashSet<>( Arrays.asList( REGIONS ) ); out.println( regions.contains( "RI" ) ); } }