Java
ä»ã¾ã§ã¯ã©ã¹ãã¡ã½ããã«å¯¾ãã¦å®£è¨ã§ããã¢ããã¼ã·ã§ã³ããJava8ããå¤æ°ã®åãã¸ã§ããªãã¯ã¹ã®åã«å¯¾ãã¦ãã¢ããã¼ã·ã§ã³ãå®ç¾©ãããã¨ãã§ããããã«ãªãã¾ããã ãã ã注æç¹ã¨ãã¦ãããã¾ã¦å®£è¨ã§ããããã«ãªã£ãã ãã§ããã©ã«ãã§Javaã«å ¥ã£â¦
Java8ã«ã¤ãã¦èª¿ã¹ãã¨ãæ¨æºã§ç¨æããã¦ããé¢æ°åã¤ã³ã¿ã¼ãã§ã¤ã¹é¢æ°ã®å¤ãã«ã³ã£ããããã SupplierãConsumerãPredicateãFunctionãUnaryOperatorãBinaryOperatorãetc.. å ¨é¨ã§40以ä¸ã¯ãããæ£ç´ã¯ããã¯ããå ¨é¨è¦ããã®ãã¨ãããªãæ鬱ã ã£â¦
ããããOptionalã¨ã¯ Optionalã¯Tåã®ãªãã¸ã§ã¯ãã«å¯¾ããã©ããã¼ã§ããªãã¸ã§ã¯ããnullãã©ãããå¤æããããnullã ã£ãå ´åã®ããã©ã«ãå¤ãè¨å®ã§ããJava8ãã追å ãããã¯ã©ã¹ã Nullãªãã¸ã§ã¯ãã«è¿ãæãã§ããããã ã©ããã£ãã¨ããã§ä½¿ãã®â¦
Java8ããæååã®çµåæ¹æ³ãããã¤ã追å ãããã®ã§ãç°¡åã«ã¾ã¨ãã¾ããã StringJoiner Java8ããæ°ãã追å ãããã¯ã©ã¹java.util.StringJoinerã åºåãæåããµãã£ãã¯ã¹ããã¬ãã£ãã¯ã¹ãåãã¦æååãé£çµã§ããã®ã§ 便å©ã©ã¤ãã©ãªGuavaã®Joinerâ¦
å æ¥CodeIQã§ã©ã³ãã ãã¹ã¯ã¼ããçæããããã°ã©ã ã®åé¡(ææ¦è æ±ãï¼ãã¦ãã«æ¥ãªãï¼ã[Java]ã©ã³ãã ãã¹ã¯ã¼ãã®ä½æ by CodeIQéå¶äºåå± ã¢ããªã±ã¼ã·ã§ã³ã¨ã³ã¸ãã¢ãåéããä¼æ¥âCodeIQ) ã§è§£çããéã«ä½¿ã£ãã©ã³ãã æååçæã®ã¡ã¢ã§ãããâ¦
ã»ãã¥ã¹ãã®åå¼·ãã¦ãã«IPAã®ãµã¤ããè¦ã¦ãããããªã¼ããªã³ãªã¼ã¤ã³ã¿ãã§ã¼ã¹ ã¨ããèãæ¹ããã£ã¦ããªãã»ã©ã¼ã£ã¦æã£ããããã®ã§ããã®å 容ãå°ãããã«ãã»ã«åã®ããããã¨é¡ãããã®å 容ã¯ç°¡åã«è¨ãã¨ã¯æ®æ®µgetterã¨setter ãæ¸ãã¦ããã¯ã©ã¹â¦
è¥å¹²ä»æ´æã¯ãããã©ãtwitter4jã触ãæ©ä¼ããã£ãã®ã§ãã¨ããããã以ä¸ã®ï¼æ©è½ãç°¡åã«å®è£ ãã¦ã¿ããã»OAuthèªå¯ãã¤ãã£ã¦ãã¤ã¼ãããã ã»æå®ããã¦ã¼ã¶ã®ã¿ã¤ã ã©ã¤ã³ãåå¾ããã ã»ãã¤ã¼ãã®æ¤ç´¢ããããâ æºå ï¼ï¼ãªã«ã¯ã¨ããããã¾ãã¯twiâ¦
ã·ã³ã°ã«ãã³ã®çæã®æ¹æ³ã¯ããè°è«ãããã¨ãããªãã ãã©ã ããã¨ã¯å¥ã«ã·ã³ã°ã«ãã³ã¯ã©ã¹ã®å¤æ°ã®åæåã«é¢ãã¦å°ãäºæ³å¤ã®æåãèµ·ããã®ã§ã ã¡ã¢ãã¦ããããã¨æãã public class Sample { public static void main(String args[]) { Single.geâ¦
Junitã§ãã¹ããæ¸ãã¦ããããã©ããã¦ãæååãä¸è´ããªãã®ã±ã¼ã¹ããã£ã¦å°ã調ã¹ã¦è¦ãããã©ãããæ¹è¡ã³ã¼ãã®æå®ã®ä»æ¹ã«åé¡ããã£ãã¿ããããã¹ãã±ã¼ã¹ã¯ä»¥ä¸ã®ãããªæãã @Test public void test() { // ãã¡ã¤ã«ã¨ãããæååãåå¾ Striâ¦
æè¿ãjava.util.HashMapããã¹ã¬ããã»ã¼ããããªããã¨ãç¥ã£ã¦ ããã«ã¤ãã¦ãããã調ã¹ã¦ã¿ããã¾ãããjava.util.HashMapãã¯ã¹ã¬ããã»ã¼ããããªããããè¤æ°ã¹ã¬ããã並è¡ãã¦HashMapã«ã¢ã¯ã»ã¹ããå ´åã¯ããã·ã¥ãã¼ãã«ã®ç ´å£ã¨ãç¡éã«ã¼ããâ¦
JDK1.5ããã¹ã¬ããã»ã¼ããªã¯ã©ã¹ãè²ã ã¨è¿½å ããã¦ããã¿ããã ä¸ã§ããAtomicInteger ã¨ãã¯ä¾¿å©ã§ä½¿ãæãå¤ãããã ä¸ã¯ã¹ã¬ããã»ã¼ããªå¤ãæ´æ°ãããµã³ãã«ä»ã¾ã§ã®å®è£ class Atomic { private int count = 0; public synchronized void add(intâ¦
whileæã§Iteratorã使ãå ´åã®æ¬ ç¹ã¨ãã¦ãã¼ã«ã«å¤æ°(以ä¸ã®ä¾ã®å ´åãitã)ã®æå¹ç¯å²ãåºããããã«ããitãã¨ããå¤æ°åãåå©ç¨ã§ããªãã¨ãã£ããã¨ãããã ãªã®ã§Iteratorã使ãå ´åã¯whileæãããªãã¦foræã®ä¸ã§ä½¿ã£ãæ¹ãããããã£ã¦ãããã¨â¦
Jakarta Commons CLI ã¨ãããã®ãæè¿ããã®ãç¥ã£ãã®ã§ãå°ã調ã¹ã¦ã¿ãããã¡ããã³ãã³ãã©ã¤ã³ãªãã·ã§ã³è§£æã©ã¤ãã©ãªã¨ãããã¨ã ãã©ãã¤ã¾ãã¯ã·ã§ã«ã¹ã¯ãªããã¨ãã§javaãå¼ãã ãããã¨ãã«ãoptionããhelpã¨ããç°¡åã«å®è£ ã§ããã©ã¤ãã©ãªâ¦
ã¡ã½ããã®å¼æ°ãä¸æ£ã ã£ãå ´åã« IllegalArgumentException ãthrowããã®ã¯ãã使ã£ã¦ããããã¦ãããã©ããã 以ä¸ã®ãããªæãã§ã public void regist(String name) { // å¼æ°ãã§ã㯠if (name == null) { throw new IllegalArgumentException("å¼æ°â¦
SimpleDateFormatã¯åºæ¬çã«ã¯ä»¥ä¸ã®æ§ã«ã¯ã©ã¹å¤æ°ã¨ãã¦å®£è¨ãããã®ã¨æã£ã¦ããã æ¯ånewããã®ãå¾®å¦ã ã¨æã£ã¦ã private static final DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); public void func () { } ãã ããã®ããã«å®è£ ãã¦ãã¾â¦
Javaã®ãã¡ã¤ã«æä½ã§ãã£ã¬ã¯ããªãåé¤ãããã¨æã£ãããä¸ã®ãµããã£ã¬ã¯ããªã¨ãã¡ã¤ã«ãåé¤ããªãã¨å¤±æãã¦ãã¾ãã®ã§ããããã以ä¸ã®æ§ãªé·ãå¦çãæ¸ããªãã¨ãããªãã ãã ããã£ã¬ã¯ããªãåé¤ãããã ããªã®ã«ãããâ»ä¸æ§ãã¡ã¤ã«ã®å ´åã§ãâ¦
å ¨è§ã²ãããªãæååããåé¤ããæ¹æ³ãæ¢ãã¦ããã¨ããã以ä¸ã®æ¹æ³ããããã¨ãç¥ã£ã¦å°ãé©ããã"abcããã123".replaceAll("[\\p{InHiragana}]", ""); çµæï¼abc123ãã 調ã¹ãæãã ã¨ã\p{InHiragana}ã¯åã«ã²ãããªã®ç¯å²æå®ãæååã«ç½®ãæãã¦â¦
ãã¼ã«ã«å¤æ°ã«final修飾åãã¤ããã®ã£ã¦ãããéåæããã£ãã®ã§ããããã調ã¹ã¦è¦ããã©æ確ãªçãããªããªãç¡ãã£ãã ã¤ã³ãã¼ã¯ã©ã¹ããã¢ã¯ã»ã¹ã§ããããã«ããã¨ãã£ãå é¨ã¯ã©ã¹çµ¡ã¿ãªãããããã©ãå人çã«ã¯ãã以å¤ã§ã¤ããæå³ã£ã¦ãããâ¦
ããªãã¼ãå¦çã®æ¡ä»¶ã¨ãã¦ãè±æ°åã®ã¿ã¨ãããå ´åã«Characterã¯ã©ã¹ã®isLetterOrDigitã¨ãããã®ããããããã以ä¸ã®ããã«ä½¿ãã¨æ¤ç¥ã§ããã String text = "ABC123ããã#$%"; for (char c : text.toCharArray()) { // è±æ°åã®å ´åã¯åºå if(Characâ¦
å¤æ°ããã£ã¼ã«ãä¸ã§åæåããããã³ã³ã¹ãã©ã¯ã¿ã§åæåãããã§è¿·ã£ãã¨ãã¯ã³ã³ã¹ãã©ã¯ã¿ã®ã§åæåãããã»ããããããã ãã£ã¼ã«ãä¸ã§åæå class Sample { private Hoge hoge = new Hoge(); } ã³ã³ã¹ãã©ã¯ã¿ã§åæå public class Sample { pâ¦
以åãããªifæãè¦ããã¨ãããã Boolean boo = true; if (boo == Boolean.TRUE) { ...dosomething } ifæã§ã®booleanã¯ä»¥ä¸ã®ç¨ã«è¨è¿°ãããã®ã ã¨ãã£ã¨æã£ã¦ããåã«ã¯å°ãè¡æçã ã£ãã if (boo) { ...dosomething } ããã§ãµã¨ããçåã«ã¶ã¤ãã£ã¦â¦
å®è£ ãã¦ããã¨ãã¾ã«ããã®ã¡ã½ããã¯staticã«ããã¹ããããªãã¹ããä¸ç¬è¿·ã£ã¦ãã¾ããã¨ãããã ãã®ã¨ãã®åèã®ããã«ç°¡åã«ã¾ã¨ãã staticãªã¡ã½ããã®ããã¤ãã®ç¹å¾´ ã»staticãªã¡ã½ããã¯ã¤ã³ã¹ã¿ã³ã¹ã¨ã¯é¢ä¿ãªããããéstaticãã£ã¼ã«ããéstâ¦