Home | Gaming | Programming | Play Online | Submit Article | Submit BETA | Advertise | Contact | Keyword Query | Trade Games
Games++ Games & Game Programming

GAMES++
Games++ Home
Games++ Gaming
Games++ Programming
Beta Testing Games
Free Online Games
Hints & Cheats

BROWSER UTILITIES
E-mail This Page
Add to Favorites

SITE SEARCH

Web Games++

AFFILIATES
Cheat Codes
Trickster Wiki
Game Ratings
Trade Games
Gameboy Cheats
PlayStation Cheats
BlackBerry Games
Photoshop Tutorials
Illustrator Tutorials
ImageReady Tutorials
Tutorial Bus
Fresh Tutorials

ADVERTISEMENT

Define An Array of Functions

Java: How To

public class testf 
{
   public static void main(String args[])
   {
      Command[] commands = new Command[3];                                   
      commands[0] = new aCommand();
      commands[1] = new bCommand();
      commands[2] = new cCommand();
      commands[0].exec();
      commands[1].exec();
      commands[2].exec();
   }
}

class aCommand implements Command 
{
   public void exec() 
   {
      System.out.println("a");
   }
}

class bCommand implements Command 
{
   public void exec() 
   {
      System.out.println("b");
   }
}

class cCommand implements Command 
{
   public void exec() 
   {
      System.out.println("c");
   }
}

interface Command 
{
   void exec();
}

Copyright © 1998-2007, Games++ All rights reserved. | Privacy Policy