Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- function interact()
- {
- var name = prompt("What is your name?");
- alert("Hi, " + name);
- }
- </script>
- <button onclick="interact()">Interact</button>
- //An innocuous looking method which will become known as a callback method
- //because of the way in which we will invoke it.
- int meaningOfLife(void) {
- return 42;
- }
- //An innocuous looking method which just takes an int and prints it to screen
- void Print_A_Number(int a_Number) {
- System.out.print(a_Number);
- }
- //invoking a method which passes another method as an argument in reaction to an event (the 'another' method - meaningOfLife - is therefore called a callback method) and the event - main() - is that the program is starting
- void main() {
- Print_A_Number(meaningOfLife);
- }
Add Comment
Please, Sign In to add comment