GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — function-pointers/FunctionPointerDemo.java at master · upperdim/function-pointers Expand file tree/ Copy pathFunctionPointerDemo.javaMore file actions 25 lines (19 loc) · 540 Bytes / Copy pathFunctionPointerDemo.javaFile metadata and controls25 lines (19 loc) · 540 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 import java.util.Arrays; interface FunctionWrapper { int methodSignature(int n); } public class FunctionPointerDemo { static int increment(int n) { return n + 1; } static void myObjective(int[] arr, FunctionWrapper f) { for (int i = 0; i < arr.length; ++i) arr[i] = f.methodSignature(arr[i]); } public static void main(String[] args) { int[] arr = {0, 1, 2 ,3 ,4}; FunctionWrapper functionPointer = FunctionPointerDemo::increment; myObjective(arr, functionPointer); System.out.println(Arrays.toString(arr)); } } |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |