zoukankan      html  css  js  c++  java
  • 类名+函数名(参数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    }
  • 相关阅读:
    求助:C#读文本文件(编码未知)的问题
    求助:字符的显示问题
    常用的xml文件操作
    关于旧表导入新表的数据冲突问题
    通过批处理管理安装windows服务
    windows服务,批处理安装
    ajax的请求的超时处理
    消息队列的使用
    c#程序执行cmd命令
    dynamic(翻译)
  • 原文地址:https://www.cnblogs.com/lubocsu/p/5061425.html
Copyright © 2011-2022 走看看