• 0921-----In class to practive-----enlish starts


     1 //client class
     2 public class Text1{
     3     //main function
     4     public static void main(String args[]){
     5         Robot r1=new Robot(){
     6             public void run(){
     7                 System.out.println("I can running too.");
     8             }
     9             public void jump(){
    10                 System.out.println("I can jumpping too.");
    11             }
    12         };
    13         r1.run();
    14         r1.jump();
    15         Robot r2=new T200();
    16         r2.jump();
    17         r2.run();
    18         r2.listen();
    19         
    20         //comments implements
    21         // Runnable implements one
    22         Runnable r11=new Runnable(){
    23             public void run(){
    24                 System.out.println("I am java 7!");
    25             }
    26         };
    27         r11.run();
    28 
    29         //java 8 implements
    30         // Runnable implements two
    31         Runnable r22=()->System.out.println("I am java 8!");
    32         r22.run();
    33 
    34         //java 8 implements
    35         ICpu cpu=(String str)->System.out.println(str);
    36         cpu.start("Cpu is starting working!");
    37     }
    38 }
    39 //Robot class
    40 //if the class has an abstract function , then the class must be an abstract class
    41 //the abstract class must not be hasing an abstract function
    42 abstract class Robot{
    43     //listenning
    44     public void listen(){
    45         System.out.println("I can listenning.");
    46     }
    47     //speaking
    48     public void speak(){
    49         System.out.println("I can speaking.");
    50     }
    51     //running
    52     //abstract function
    53     public abstract void run();
    54     //jumpping
    55     //abstract function
    56     public abstract void jump();
    57 }
    58 //T100 extends Robot
    59 abstract class T100 extends Robot{
    60     public void run(){
    61         System.out.println("I can running.");
    62     }
    63     public abstract void jump();
    64 }
    65 //T200 extends Robot
    66 class T200 extends T100{
    67     public void jump(){
    68         System.out.println("I can jumpping.");
    69     }
    70 }
    71 //interface example
    72 interface ICpu{
    73     //const only
    74     //abstract function only
    75     //the default modifier is public and abstract
    76     double PI=3.1415927;
    77     void start(String str);
    78 }
  • 相关阅读:
    SP是什么?CP是什么?SP与CP有什么区别?
    SP与CP将走向互补融合
    SP与CP分工
    Asynchronous Socket 顺序
    Asynchronous Client Socket Example
    Synchronous Server Socket Example
    web应用程序根目录
    简单socket服务(一)
    Asynchronous Server Socket Example
    Socket连接不上的问题
  • 原文地址:https://www.cnblogs.com/kaililikai/p/5892962.html
Copyright © 2020-2023  润新知