In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces how to use the JAVA interface to achieve multi-implementation classes, which has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to understand it.
Class NoteBook {/ / Notebook enables the running function public void run () {System.out.println ("Notebook running") } / / Notebook uses usb device. When the notebook object calls this function, it must pass a USB device public void useUSB (USB usb) that conforms to USB rules {/ / to determine whether there is a USB device if (usb! = null) {usb.open (); usb.close () }} public void shutDown () {System.out.println ("Notebook closed");}} public class Test {public static void main (String [] args) {/ / create notebook entity object NoteBook nb = new NoteBook (); / / Notebook opens nb.run (); / / create mouse entity object Mouse m = new Mouse () / / Notebook uses mouse nb.useUSB (m); / / creates keyboard entity object KeyBoard kb = new KeyBoard (); / / Notebook uses keyboard nb.useUSB (kb); / / Notebook closes nb.shutDown ();}} class KeyBoard implements USB {public void open () {System.out.println ("Keyboard on") } public void close () {System.out.println ("keyboard off");}} class Mouse implements USB {public void open () {System.out.println ("mouse on");} public void close () {System.out.println ("mouse off");}} interface USB {void open (); / / enable void close () / / close function} Thank you for reading this article carefully. I hope the article "how to use JAVA interface to implement multiple implementation classes" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.