• About Me
  • My Slides

WindyGallery's Weblog

~ I am a normal man in quite imperfect little World.

WindyGallery's Weblog

Monthly Archives: December 2009

Java: How to use interface

15 Tuesday Dec 2009

Posted by windygallery in Developer

≈ Leave a comment

Tags

interface, java

interface GunInterface {
public void shot();
}

class Bomber implements GunInterface {
public void shot() {
System.out.println(“Bombbb !?”);
}
}

class Bazuka implements GunInterface {
public void shot() {
System.out.println(“Bazuka”);
}
}

public class RefreshInterface {
public RefreshInterface()    {
Bomber     bomb = new Bomber();
Bazuka    bazu = new Bazuka();
GunInterface gun = bomb;
gun.shot();
gun = bazu;
gun.shot();
((GunInterface) bomb).shot();
((GunInterface) bazu).shot();
}
public static void main(String [] argv)    {
new RefreshInterface();
}
}

Subscribe

  • Entries (RSS)
  • Comments (RSS)

Archives

  • August 2017
  • November 2015
  • August 2015
  • June 2015
  • May 2015
  • April 2015
  • March 2015
  • February 2015
  • January 2015
  • December 2014
  • November 2014
  • October 2014
  • September 2014
  • August 2014
  • July 2014
  • June 2014
  • May 2014
  • April 2014
  • March 2014
  • May 2012
  • February 2011
  • January 2011
  • August 2010
  • June 2010
  • May 2010
  • April 2010
  • February 2010
  • January 2010
  • December 2009
  • November 2009
  • October 2009
  • September 2009
  • August 2009
  • April 2009
  • March 2009
  • November 2008
  • October 2008

Categories

  • Developer
  • Events
  • Games
  • IDeas
  • Love
  • Photos

Meta

  • Register
  • Log in

Create a free website or blog at WordPress.com.

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy
  • Follow Following
    • WindyGallery's Weblog
    • Already have a WordPress.com account? Log in now.
    • WindyGallery's Weblog
    • Customize
    • Follow Following
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar