Skip to content

Instantly share code, notes, and snippets.

@ochim
Created December 15, 2016 06:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ochim/24baa652d99e9583001c310b0bc69d22 to your computer and use it in GitHub Desktop.
Save ochim/24baa652d99e9583001c310b0bc69d22 to your computer and use it in GitHub Desktop.
[java]配列オブジェクトからArrayListへ変換

配列オブジェクトからArrayListへ変換をしたいときに、いちいちfor文とかを使わない方法

public class AAAA {
	public static void main(String[] args) throws UnsupportedEncodingException {

		String [] str = { "ichika","kaito","kanna","tetsurou","mio","remmon"};
		ArrayList al = new ArrayList(Arrays.asList(str));

		Iterator it = al.iterator();
		while (it.hasNext()) {
			System.out.println((String)it.next());
		}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment