ãã¾ã«ãJava ã® Enumeration ã使ã£ããµã³ãã«ãè¦ããããã¨ãããã¾ããããã®å¤§åã Iterator ã¨åããããªã¢ã¯ã»ã¹ã®ä»æ¹ããã¦ãã¾ãã
NetworkInterface nic = NetworkInterface.getByName("eth0"); Enumeration<InetAddress> nicAddress = nic.getInetAddresses(); while(nicAddress.hasMoreElements()){ InetAddress address = nicAddress.nextElement(); ï¼ä»¥ä¸çç¥ï¼
ã§ããã¡ãã£ã¨å·¥å¤«ãã¦æ¡å¼µ for æã使ã£ãæ¹ãè¦ãããã§ãã
NetworkInterface nic = NetworkInterface.getByName("eth0"); for(InetAddress address : Collections.list(nic.getInetAddresses())){ ï¼ä»¥ä¸çç¥ï¼
Enumeration 㯠æ¡å¼µ for æã§ä½¿ãã¾ããããList ãªã OK ã§ãã
ããã§ãCollections.list(…) ã使ã£ã¦ãEnumeration ã ArrayList ã«å¤æãã¦ã¿ã¾ããã
ãªã¼ãã¼ããããããããããã¾ãã*1ãããã£ã¡ã®ã»ããåãããããã®ã§å¥½ãã§ãã