Source Code : Converts a char array to a Set
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Converts a char array to a Set
/*
* The contents of this file are subject to the Sapient Public License
* Version 1.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* http://carbon.sf.net/License.html.
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* The Original Code is The Carbon Component Framework.
*
* The Initial Developer of the Original Code is Sapient Corporation
*
* Copyright (C) 2003 Sapient Corporation. All Rights Reserved.
*/
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
/**
* <p>Utilities for strings.</p>
*
*
* Copyright 2002 Sapient
* @since carbon 1.0
* @author Greg Hinkle, May 2002
* @version $Revision: 1.5 $($Author: dvoet $ / $Date: 2003/05/05 21:21:24 $)
*/
public class StringUtil {
/**
* <p> Converts a string to a Set. Breaks the string to characters and store
* each character in a Set.
*
* @param string the string to convert
* @return a <code>Set</code> containing all characters in the text string parameter
*/
public static Set convertToSet(String string) {
// Result hashset
Set resultSet = new HashSet();
for (int i = 0; i < string.length(); i++) {
resultSet.add(new Character(string.charAt(i)));
}
// Return result
return resultSet;
}
/**
* <p> Converts a char array to a Set. Puts all characters in the array to a Set.
*
* @param charArray an array of <CODE>char</CODE>s
* @return a <code>set</code> containing all characters in the char array
*/
public static Set convertToSet(char[] charArray) {
// Result hashset
Set resultSet = new HashSet();
for (int i = 0; i < charArray.length; i++) {
resultSet.add(new Character(charArray[i]));
}
// Return result
return resultSet;
}
}
Thank with us