• 类名+函数名(参数1,参数2.....){.......return this;}


    下述的函数是这样定义的: 类名+函数名参数1,参数2.....{.......return this;}

                                       int +函数名(参数1,参数2.....){.......return int;}

                                       short+函数名(参数1,参数2.....){.......return short;}

                                       double+函数名(参数1,参数2.....){.......return double;} 

                                      String+函数名(参数1,参数2.....){.......return String;} 

                                       int[]+函数名(参数1,参数2.....){.......return int[];}

                                       String[]+函数名(参数1,参数2.....){.......return String[];

                                       void+函数名(参数1,参数2.....){...................................} 

     1 import java.awt.Point;
     2   class rectangle
     3     { int x1=0;
     4       int y1=0;
     5       int x2=0;
     6       int y2=0;
     7      
     8      rectangle point(int x,int y,int z,int w)
     9       {x1= x;
    10        y1= y;
    11        x2= z;
    12        y2= w;
    13        return this;
    14        }
    15      rectangle point(Point topleft,Point rightbottom)
    16       {x1=topleft.x;
    17        y1=topleft.y;
    18        x2=rightbottom.x;
    19        y2=rightbottom.y;
    20        return this;
    21         }
    22       rectangle point(Point topleft,int w,int h)
    23        { x1= topleft.x;
    24          y1= topleft.y;
    25          x2= topleft.x + w;
    26          y2= topleft.y - h;
    27         return this;
    28         }
    29       public static void main(String[] args)
    30 
    31        { rectangle experiment = new rectangle();
    32          experiment.point(1,2,3,4);
    33          System.out.print(experiment.x1+" "+experiment.y1+" "+experiment.x2+" "+experiment.y2);
    34          experiment.point(new Point(1,2),new Point(3,4));
    35          System.out.print(experiment.x1+" "+experiment.y1+" "+experiment.x2+" "+experiment.y2);
    36          experiment.point(new Point(1,2),3,4);
    37          System.out.print(experiment.x1+" "+experiment.y1+" "+experiment.x2+" "+experiment.y2);
    38         }
    39    
    40    }
  • 相关阅读:
    emacs配置emacs-clang-complete-async
    emacs之配置自动安装脚本
    vim之YCM配置
    vim之vundle
    emacs之配置php
    kettle的日志
    kettle的报错解决机制
    kettle优化
    将BAT文件注册为服务的方法
    使用powerdesinger逆向生成表结构
  • 原文地址:https://www.cnblogs.com/lubocsu/p/5061425.html
Copyright © 2020-2023  润新知