This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
double count = 0; | |
10.times { | |
count += 0.1 | |
} | |
print count |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// JDK 1.4 style | |
List oldList = new ArrayList(); | |
oldList.add(Integer.valueOf(1)); | |
int oldNumber = ((Integer) oldList.get(0)).intValue(); | |
// JDK 1.5 over | |
List<Integer> newList = new ArrayList<Integer>(); | |
newList.add(1); | |
int modernNumber = newList.get(0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.reflect.Field; | |
public class ReflectionTest { | |
public static void main(String[] args) throws Exception { | |
Mizuno mizuno = new Mizuno(); | |
System.out.println("リフレクション前 : " + mizuno.talk()); // … | |
Class<? extends Mizuno> clazz = mizuno.getClass(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.tksmaru.playgound; | |
import java.lang.reflect.Constructor; | |
public class ActiveClassWithReflection { | |
private enum ErrorType { | |
LESS_MONEY("less.money", UserException.class), | |
NO_STOCK("no.stock", ShopException.class), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.Collections; | |
import java.util.List; | |
public class CollectionUtils { | |
/** | |
* Listを指定したサイズ毎に分割します。 | |
* | |
* @param origin 分割元のList |
OlderNewer