Next2Dで始めるゲーム開発 - Game Development Starting with Next2DToshiyuki Ienaga
?
CEDEC2022に応募したのですが、見事に落選しました。
が、折角作った資料なので公開します。
I applied for CEDEC2022, but was not selected.
However, I am publishing this document because I made it at an opportunity.
Next2Dで始めるゲーム開発 - Game Development Starting with Next2DToshiyuki Ienaga
?
CEDEC2022に応募したのですが、見事に落選しました。
が、折角作った資料なので公開します。
I applied for CEDEC2022, but was not selected.
However, I am publishing this document because I made it at an opportunity.
10. 匿名クラス
List<Integer> numbers = Arrays.asList(7, 3, 5);
Collections.sort(numbers, new Comparator<Integer>() {
@Override
public int compare(Integer o1, Integer o2) {
int n = o1 % 5;
int m = o2 % 5;
return n - m;
}
});
13年8月9日金曜日
15. public class LambdaSample {
public static void main(String[] args) {
Calculator sum = (n, m) -> n + m;
operate(3, 2, sum); // => 5
Calculator diff = (n, m) -> {
if (n >= m) {
return n - m;
} else {
return m - n;
}
};
operate(3, 2, diff); // => 1
operate(3, 2, (n, m) -> n * m); // => 6
}
public static void operate(int n, int m, Calculator c) {
System.out.println(c.calculate(n, m));
}
}
public interface Calculator {
int calculate (int n, int m);
}
13年8月9日金曜日
19. public interface Calculator {
int calculate(int n, int m);
}
public class Sample {
public static void main(String[] args) {
operate(6, 2, (n, m) -> n + m); // => 8
operate(6, 2, Sample::div); // => 3
}
public static void operate(int n, int m, Calculator c) {
System.out.println(c.calculate(n, m));
}
public static int div(int o1, int o2) {
return o1 / o2;
}
}
13年8月9日金曜日
26. public class SimpleInterfaceImpl implements SimpleInterface {
@Override
public void doWork() {
System.out.println("doWork in implement class");
}
public static void main(String[] args) {
SimpleInterface impl = new SimpleInterfaceImpl();
impl.doWork(); // => doWork in implement class
impl.doOtherWork(); // => doOtherWork in interface
}
}
public interface SimpleInterface {
public void doWork();
default public void doOtherWork() {
System.out.println("doOtherWork in interface");
}
}
13年8月9日金曜日