`
rita_ka
  • 浏览: 10944 次
  • 性别: Icon_minigender_2
  • 来自: 广州
社区版块
存档分类
最新评论

数组总结

    博客分类:
  • Java
 
阅读更多


8.1.学习了数组


一、
   一维数组
           格式:  1.数据类型 [] 对象名= new 数据类型[数组长度];
                   2.数据类型 [] 对象名= new 数据类型[]{a,b...};
                   3.数据类型 [] 对象名;
                     对象名 = new 数据类型[数组长度]

 

二、
   二维数组
         格式:  1.数据类型 [][] 对象名= new 数据类型[行][列];
                 2.数据类型 [][] 对象名= new 数据类型[][]{a,b...};
                 3.数据类型 [][] 对象名;
                   对象名 = new 数据类型[行][列];

  


/*************************练习***************************/

       1.一维数组排序(每个人必须要实现3-4排序方法)
       2.二维数组找出最大的值
       3.使用数组实现画板图形重绘


/******************** 一维数组排序 **********************/

/*****遇到问题&解决方法*******/

遇到问题:
    写方法函数的时候报错,要加个static才行。
解决方法:
     在入口函数中要新建一个函数对象,不然后面的函数都要用到static。
     static 表示静态,占内存的一小块空间,不建议用。

/***代码***/

package Array;

import java.util.Random;

//用不同的方法排列一维数组
public class ArrayOne {

 /**定义入口主函数
  * @param args
  */
 public static void main(String[] args) {
  //实例化一个对象是个好事!很多事情都好办多了! 要是没有实例化,函数前面都要用

static!
  ArrayOne ao = new ArrayOne();
 
  /**
   * 用冒泡方法排序
   */
  System.out.println("1.用冒泡方法排序:");
            int [] Array = ao.CreateArray(10);
      System.out.println("原始数据:");
            ao.printArray(Array);
      System.out.println("用冒泡方法排序后数据:");
            ao.Bubble(Array);
            ao.printArray(Array);
            System.out.println();
            System.out.println();
           
        /**
         * 用选择方法排序
         */
        System.out.println("2.用选择方法排序:");
            int [] Array1 = ao.CreateArray(10);
      System.out.println("原始数据:");
            ao.printArray(Array1);
            ao.Choose(Array1);
      System.out.println("用选择方法排序后数据:");
            ao.printArray(Array1);
            System.out.println();  
            System.out.println();
 
         /**
          * 用插入方法排序  
          */
         System.out.println("3.用插入方法排序:");
            int [] Array2 = ao.CreateArray(10);
      System.out.println("原始数据:");
            ao.printArray(Array2);
            Insert(Array2);
      System.out.println("用插入方法排序后数据:");
            ao.printArray(Array2);
            System.out.println();  
            System.out.println();
 
          /**
           * 用希尔方法排序  
           */
  System.out.println("4.用希尔方法排序:");
     int[] Array3 = ao.CreateArray(10);
     System.out.println("原始数据:");
     ao.printArray(Array3);
     Shell(Array3);
     System.out.println("用希尔方法排序后数据:");
     ao.printArray(Array3);
     System.out.println();
           System.out.println();

 }//main
 
    /**
     * 创建新一维数组
     * @param length
     * @return
     */
 public  int[] CreateArray(int length){
  //定义一个新的一位数组
  int []ArrayOne = new int[length];
  //用随机数定义数组元素
  Random rand = new Random();
  //给数组元素赋值
  for(int i = 0;i<ArrayOne.length;i++){
   ArrayOne[i] = rand.nextInt(100)+500;
  }  
  return ArrayOne;
 }
 
 /**
  * 打印一维数组
  * @param Array
  */
 public void printArray(int[] Array){
  for(int i = 0;i<Array.length;i++){
   System.out.print(Array[i]+"  ");
  }
  System.out.println();
 }
 
 
 /**
  * 冒泡排序
  * @param Array
  */
 public void Bubble(int [] Array){
  //遍历数组
  for(int i = Array.length-1;i>0;--i){
   for(int j = 0; j<i; ++j){
    if(Array[j]>Array[j+1]){
     //交换
     int temp = Array[j];
     Array[j] = Array[j+1];
     Array[j+1] = temp;
      }
   }
  }
 }//Bubble
 
 
 /**
  * 选择排序
  * @param Array
  */
 public void Choose(int [] Array){
  
  //遍历数组
  for(int i = 0;i<Array.length;i++){
   int index = i;
   for(int j = i+1 ;j<Array.length;j++){
    //判断大小
    if(Array[j]<Array[index]){
     index = j;
    }    
   }
   //交换
   int temp = Array[i];
   Array[i] = Array[index];
   Array[index] = temp;
  }
 }//Choose
 
 /**
  * 插入排序
  */
 public static void Insert(int [] Array){
  //遍历数组
  for(int i = 1; i<Array.length;i++){
   for(int j = i;j>0;j--){
    //比较大小
    if(Array[j]<Array[j-1]){
     int temp = Array[j];
     Array[j] = Array[j-1];
     Array[j-1]= temp;
    }
   }
  }
 }//Insert
 
 /**
  * 希尔排序(不太懂~~~ )
  */
 public static void Shell(int [] Array){
  
  for(int increment = Array.length/2; increment>0;increment/=2){
   //每个组内排序
   for(int i = increment;i<Array.length;i++){
    int temp = Array[i];
    int j = 0;
    for(j = i;j>=increment;j-=increment){
     if(temp < Array[j-increment]){
      Array[j] = Array[j-increment];
     }else{
      break;
     }
    }
    Array[j] = temp;
   }
  }
 }//Shell
 
}


/******************** 二维数组找出最大的值 **********************/

/*****遇到问题&解决方法*******/

遇到问题:
    这个定义为二维数组,但是循环数组的时候,【 i<对象名.cloumn/row 】是不行的!
解决方法:
     Java的数组跟C++的数组有些不一样,可以把Java的数组看成是一维的。
     一位数组可以放的数据类型,可以是8大基本类型,String类,还可以是类类型的。
     所以,想得到行跟列的长度时候。用【i<对象名.length/ i<对象名[i].length】 才行!

/***代码***/

package Array;

import java.util.Random;

public class ArrayTwo {
 /**定义入口主函数
  * @param args
  */
 public static void main(String[] args) {
  //实例化一个对象
  ArrayTwo at = new ArrayTwo();
  
  //下面的数据表示二维数组里有多个最大值的时候都能输出各自的下标
  System.out.println("固定数据:");
  int [][]Array = {{1,2,3},{1,2,3},{1,2,3}};
  at.PrintArray(Array);
  int max = at.ArrayMax(Array);
  System.out.println("二维数组最大值:"+max);
  at.Search(Array, max);
  System.out.println();
  
  //随机数据
  System.out.println("随机数据:");
  int [][]Array1 = at.CreateArrayTwo(4,4);
  at.PrintArray(Array1);
  max = at.ArrayMax(Array1);
  System.out.println("二维数组最大值:"+max);
  at.Search(Array1, max);
  //at.Search(Array, max);   当Array是上面数据的时候,这行不输出,为什么?   因为

Max改变了!

 }


 private int [][] maxArray;
 
 /**
  * 创建一个二维数组
  */
 public int [][] CreateArrayTwo(int Row,int Column){
  int [][] arraytwo = new int[Row][Column];
  Random rand = new Random();
  for(int j = 0;j<arraytwo.length;j++){
   for(int i = 0;i<arraytwo[j].length;i++){
    arraytwo[i][j] = rand.nextInt(200)+100;
   }
  }
  return arraytwo;
 }//CreateArrayTwo
 
 /**
  * 打印一个二维数组
  * @param Array
  */
 public void PrintArray(int [][]Array){
  for(int j = 0;j<Array.length;j++){
   for(int i = 0;i<Array[j].length;i++){
    System.out.print(Array[i][j]+"   ");
   }
   System.out.println();
 }
 }//PrintArray
 
 /**
  * 找到最大值,并打印最大值,最大值对应的行跟列数
  * @return
  */
 public int ArrayMax(int [][]Array){
  //定义个初始比较值
  int max = Array[0][0];
  //遍历数组找最大值
  for(int j = 0;j<Array.length;j++){
   for(int i = 0; i<Array[j].length;i++){
    if(Array[i][j]>=max){
     max = Array[i][j];
      }
   }//i
  }//j
  return max;
 }//ArrayMax;
 
 /**
  * 找到最大值下标
  */
 public void Search(int [][] Array,int max){
  //遍历数组,找到最大值的下标
  for(int j = 0;j<Array.length;j++){
   for(int i = 0;i<Array[j].length;i++){
    if(Array[i][j]==max){
     System.out.println("最大值下标为: i:"+i+"  j:"+j);
    }
   }
  }
 }
}//ArrayTwo

 

/******************** 用数组实现画板图形重绘 **********************/

/*****遇到问题&解决方法*******/

遇到问题:
    1.用for循环取出Shape数组元素的时候,报错。
    2.画布不在panel上,而在jframe上
    3.用roundrect的时候异常
解决方法:
     1.在取出Shape数组元素时必须判空! if(Shape[i]==null) return;   !
       不然一开始就报错,因为一开始数组是空的。
       建议新建一个对象接受数组元素对象,看起来比较简洁。

     2.把重绘方法用匿名内部类放到new JPanel(){//重绘方法..};才行!  不知道为什么~~

     3.因为变量错了~ 粗心的原因。

/***代码***/

/*********1.入口主函数************/
package drawing;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JColorChooser;
import javax.swing.JFrame;
import javax.swing.JPanel;


public class Drawing1 extends JFrame{
 
 public static void main(String [] args){
  Drawing1 dr = new Drawing1();
  dr.initUI();
 }
 
 //全局变量
 private Shape [] sp = new Shape[10000];
 private Shape [] sp1 = new Shape[1000];
 private Shape [] sp2 = new Shape[1000];
 private Shape [] sp3 = new Shape[1000];

 private String shape;
 private Color color; 
    JPanel centerpanel;
 
 public String getshape(){
  return shape;
 }
 
public void initUI(){
 
 //实例化一个简单画板
 this.setTitle("简单画板");
 this.setSize(800,500);
 this.setDefaultCloseOperation(3);
 this.setLocationRelativeTo(null);
 
 /*********画板北边************/
 JPanel northpanel = new JPanel();
 northpanel.setSize(new Dimension(0,100));
 northpanel.setBackground(color.orange);
 //添加按钮
 JButton jbline = new JButton("line");
 JButton jboval = new JButton("oval");
 JButton jbrect = new JButton("rectangle");
 JButton jbroundrect = new JButton("roundrect");
 JButton jbtriangle = new JButton("triangle");
 //JButton jbpolygon = new JButton("polygon");
 JButton jbpencil = new JButton("pencil");
 JButton jbclear = new JButton("clear");
 //选择颜色按钮,点击后,弹出颜色选择器
   JButton bu_color = new JButton("选颜色");
   //设置按钮监听器
   bu_color.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e){
     showColorSelecter();
    }
   });
   
   //创建三个单选按钮
 
 //给按钮添加获取按钮文本事件,用匿名内部类,事件中代码不超过4行
    ActionListener al = new ActionListener(){
  @Override
  public void actionPerformed(ActionEvent e) {
   // TODO Auto-generated method stub
   shape = e.getActionCommand();
   }   
 };
 System.out.println("shape:"+shape);
 //给按钮添加事件
 jbline.addActionListener(al);
 jboval.addActionListener(al);
 jbrect.addActionListener(al);
 jbroundrect.addActionListener(al);
 jbtriangle.addActionListener(al);
 //jbpolygon.addActionListener(al);
 jbpencil.addActionListener(al);
 jbclear.addActionListener(al);
 //把按钮添加到面板上
 
 northpanel.add(jbline);
 northpanel.add(jboval);
 northpanel.add(jbrect);
 northpanel.add(jbroundrect);
 northpanel.add(jbtriangle);
 //northpanel.add(jbpolygon);
 northpanel.add(jbpencil);
 northpanel.add(bu_color);
 northpanel.add(jbclear);
 
 this.add(northpanel,BorderLayout.NORTH);
 
 /*********画板中间*********/
 //创建中间面板,白色底
 centerpanel = new JPanel(){
  public void paint(Graphics g){
   super.paint(g);
   //方法体
   repaintline(g,sp);
   repaintoval(g,sp1);
   repaintrect(g,sp2);
   repaintroundrect(g,sp3); 
  }
 };
 centerpanel.setBackground(Color.WHITE);
 this.add(centerpanel,BorderLayout.CENTER);
 
 //设置可见
 this.setVisible(true);
 
 //设置可见之后才能创建画布,获取画布对象,加到面板上
 Graphics g = centerpanel.getGraphics();
 
 //实例化一个DrawListener对象,从画布获取
 DrawingListener1 dl = new DrawingListener1(g,this,sp,sp1,sp2,sp3);
 
 //给事件源添加一个监听方法MouseListener,绑定对象;
 centerpanel.addMouseListener(dl);
 centerpanel.addMouseMotionListener(dl);
 //paint(g); 
 
}//initUI

//当点击颜色选择按钮时,显示颜色选择器,并得到用户选中的颜色;
 private void showColorSelecter(){
  //弹出颜色选择器:弹出在那个组件上,标题,初始化颜色单个参数要指定
  //这是JColorChooser中的一个public static方法,可直接调
  this.color = JColorChooser.showDialog(null, "请选择颜色", Color.black);
 }
/**
 * 重绘的方法要用匿名内部类放到panel上面去才行
 */
//public void paint(Graphics g){
// super.paint(g);
// //方法体
// repaintline(g,sp);
// repaintoval(g,sp1);
// repaintrect(g,sp2);
// repaintroundrect(g,sp3); 
//}
    /**
  * 重画直线,三角形,铅笔
  */
public void repaintline(Graphics g,Shape [] sp){
 
 for(int i = 0;i<sp.length;i++){
  Shape s = sp[i];
  if(s==null){
   return;
  }else
   g.setColor(Color.CYAN);
   g.drawLine(s.getX1(), s.getY1(), s.getX2(), s.getY2());  
 }

 /**
  * 重绘椭圆
  */
public void repaintoval(Graphics g,Shape [] sp1){
 for(int i = 0;i<sp1.length;i++){
  Shape s1 = sp1[i];
  if(s1==null){
   return;
  }else{
   g.setColor(Color.blue);
   g.drawOval(s1.getX1(), s1.getY1(), s1.getX2(), s1.getY2());  

}
}

 /**
  * 重绘矩形
  */
public void repaintrect(Graphics g,Shape [] sp2){
 
 for(int i = 0;i<sp2.length;i++){
  Shape s2 = sp2[i];
  if(s2==null){
   return;
  }else
  {
  g.setColor(Color.red);
  g.drawRect(s2.getX1(), s2.getY1(), s2.getX2(), s2.getY2());}
 }
  }//rect

 /**
  * 重绘圆角矩形
  */
 public void repaintroundrect(Graphics g, Shape[] sp3) {

  for (int i = 0; i < sp3.length; i++) {
   Shape s3 = sp3[i];
   if (s3 == null) {
    return;
   } else {
    g.setColor(Color.yellow);
    g.drawRoundRect(s3.getX1(), s3.getY1(), s3.getX2(), s3.getY2

(),20,20);
   }
  }
 }// rect

}


/*********2.监听器************/

package drawing;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JPanel;
import javax.swing.RepaintManager;

public class DrawingListener1 extends MouseAdapter{
  
 private Shape [] sp;
 private int count = 0; //用count表示shape数组的下标
 
 private Shape [] sp1;
 private int count1 = 0; //用count1表示shape数组的下标
 
 private Shape [] sp2;
 private int count2 = 0; //用count2表示shape数组的下标
 
 private Shape [] sp3;
 private int count3 = 0; //用count3表示shape数组的下标
 
 private int x1,y1,x2,y2,x3,y3,x4,y4;
 private Graphics g;
 private Drawing1 dr;
 private int flag = 0;
 private int gx,gy,hx,hy;
 private String shape;
 
 RepaintManager rm = new RepaintManager();

 //构造方法
 public DrawingListener1(Graphics g,Drawing1 dr,Shape[] sp,Shape[] sp1,Shape[]

sp2,Shape[] sp3){
  this.g = g;
  this.dr = dr;
  this.sp = sp;
  this.sp1 = sp1;
  this.sp2 = sp2;
  this.sp3 = sp3;
 }
 
 //按下鼠标左键
 @Override
 public void mousePressed(MouseEvent e) {
  // TODO Auto-generated method stub
  x1 = e.getX();
  y1 = e.getY();
 }
 
 //释放鼠标左键
 @Override
 public void mouseReleased(MouseEvent e) {
  // TODO Auto-generated method stub
  x2 = e.getX();
  y2 = e.getY();
  String s=dr.getshape();
  System.out.println("shape:"+s);
  /**
   * 画直线
   */
  if(s.equals("line")){
   g.setColor(Color.CYAN);
   g.drawLine(x1,y1,x2,y2);
   System.out.println("aaa");
   
   //新建一个Shape对象
   Shape sh = new Shape(x1,y1,x2,y2);
   //将图形对象存入到数组中
   sp[count] = sh;
   //让计数器加1
   count++;
   System.out.println("a");  
  }
  
  /**
   * 画椭圆,保存4个变量
   */
  else if(s.equals("oval")){
      if((x2-x1>0)&&(y2-y1>0)){
       g.setColor(Color.blue);
       g.drawOval(x1, y1, x2-x1, y2-y1);
       Shape s1 = new Shape(x1, y1, x2-x1, y2-y1);
       sp1[count1]=s1;
       count1++;
      }
      else if((x2-x1<0)&&(y2-y1>0)){
       g.setColor(Color.blue);
       g.drawOval(x2, y1, x1-x2, y2-y1);
       Shape s1 = new Shape(x2, y1, x1-x2, y2-y1);
       sp1[count1]=s1;
       count1++;
       
      }
      else if((x2-x1>0)&&(y2-y1<0)){
       g.setColor(Color.blue);
       g.drawOval(x1, y2, x2-x1, y1-y2);
       Shape s1 = new Shape(x1, y2, x2-x1, y1-y2);
       sp1[count1]=s1;
       count1++;
      }
      else if((x2-x1<0)&&(y2-y1<0)){
       g.setColor(Color.blue);
       g.drawOval(x2, y2, x1-x2, y1-y2);
       Shape s1 = new Shape(x2, y2, x1-x2, y1-y2);
       sp1[count1]=s1;
       count1++;
      }
     
     
  }
  
  /**
   * 画长方形,保存4个变量
   */
  else if(s.equals("rectangle")){
   if((x2-x1>0)&&(y2-y1>0)){
       g.setColor(Color.red);
       g.drawRect(x1, y1, x2-x1, y2-y1);
       Shape s2 = new Shape(x1, y1, x2-x1, y2-y1);
       sp2[count2]=s2;
       count2++;
      }
      else if((x2-x1<0)&&(y2-y1>0)){
       g.setColor(Color.red);
       g.drawRect(x2, y1, x1-x2, y2-y1);
       Shape s2 = new Shape(x2, y1, x1-x2, y2-y1);
       sp2[count2]=s2;
       count2++;
      }
      else if((x2-x1>0)&&(y2-y1<0)){
       g.setColor(Color.red);
       g.drawRect(x1, y2, x2-x1, y1-y2);
       Shape s2 = new Shape(x1, y2, x2-x1, y1-y2);
       sp2[count2]=s2;
       count2++;
      }
      else if((x2-x1<0)&&(y2-y1<0)){
       g.setColor(Color.red);
       g.drawRect(x2, y2, x1-x2, y1-y2);
       Shape s2 = new Shape(x2, y2, x1-x2, y1-y2);
       sp2[count2]=s2;
       count2++;
      }
  }
    
  /**
   * 画圆角长方形
   */
  else if(s.equals("roundrect")){
   if((x2-x1>0)&&(y2-y1>0)){
    g.setColor(Color.yellow);
       g.drawRoundRect(x1, y1, x2-x1, y2-y1,20,20);
       //新建一个Shape对象
    Shape s3 = new Shape(x1, y1, x2-x1, y2-y1);
    //将图形对象存入到数组中
    sp3[count3] = s3;
    //让计数器加1
    count3++;
      }
      else if((x2-x1<0)&&(y2-y1>0)){
       g.setColor(Color.yellow);
       g.drawRoundRect(x2, y1, x1-x2, y2-y1,20,20);
       //新建一个Shape对象
    Shape s3 = new Shape(x2, y1, x1-x2, y2-y1);
    //将图形对象存入到数组中
    sp3[count3] = s3;
    //让计数器加1
    count3++;
      }
      else if((x2-x1>0)&&(y2-y1<0)){
       g.setColor(Color.yellow);
       g.drawRoundRect(x1, y2, x2-x1, y1-y2,20,20);
       //新建一个Shape对象
    Shape s3 = new Shape(x1, y2, x2-x1, y1-y2);
    //将图形对象存入到数组中
    sp3[count3] = s3;
    //让计数器加1
    count3++;
      }
      else if((x2-x1<0)&&(y2-y1<0)){
       g.setColor(Color.yellow);
       g.drawRoundRect(x2, y2, x1-x2, y1-y2,20,20);
       //新建一个Shape对象
    Shape s3 = new Shape(x2, y2, x1-x2, y1-y2);
    //将图形对象存入到数组中
    sp3[count3] = s3;
    //让计数器加1
    count3++;
      }
   //g.drawRoundRect(x1, y1, width, height, arcWidth, arcHeight)
  }
  
  /**
   * 画三角形,先得到2个点,连成直线,然后在单击鼠标获取一个点,把三个点连上
   */
  else if(s.equals("triangle")){
   
   //新建一个Shape对象
   Shape sh = new Shape(x1,y1,x2,y2);
   //将图形对象存入到数组中
   sp[count] = sh;
   //让计数器加1
   count++;
   g.setColor(Color.CYAN);
   g.drawLine(x1, y1, x2, y2); 
   if(flag==0){
   gx = x1;
   gy = y1;
   hx = x2;
   hy = y2;
   }
   flag++;
   }
//  else if(s.equals("polygon")){
//   g.drawLine(x1, y1, x2, y2);
//   {
//   gx = x1;
//   gy = y1;
//   hx = x2;
//   hy = y2;
//  }  
//     flag++;
//  }
  
  /**
   * 铅笔功能
   */
  else if(s.equals("pencil")){
   mouseDragged(e);     
  }
  
 }
 
 public void mouseClicked(MouseEvent e) {
  // TODO Auto-generated method stub
  x3 = e.getX();
  y3 = e.getY();
  if((dr.getshape().equals("triangle"))&&(flag>0)){
  g.setColor(Color.CYAN);
  g.drawLine(gx,gy,x3,y3);
  g.drawLine(x3,y3,hx,hy);
  //新建一个Shape对象
  Shape sh = new Shape(gx,gy,x3,y3);
  //将图形对象存入到数组中
  sp[count] = sh;
  //让计数器加1
  count++;
  
  // 新建一个Shape对象
  Shape sh1 = new Shape(x3,y3,hx,hy);
  // 将图形对象存入到数组中
  sp[count] = sh1;
  // 让计数器加1
  count++;
  flag = 0;
  } 
  
  else if (dr.getshape().equals("clear")){
   
   dr.centerpanel.repaint();
   //centerpanel.repaint();
      System.out.println("bbb");
  } 
 }
 
 //拉拽功能
 public void mouseDragged(MouseEvent e) {
  // TODO Auto-generated method stub
  if(dr.getshape().equals("pencil")){
  x4 = e.getX();
  y4 = e.getY();
  g.setColor(Color.CYAN);
        g.drawLine(x1, y1, x4, y4);
      
        //新建个图形对象
        Shape sh = new Shape(x1, y1, x4, y4);
  //将图形对象存入到数组中
  sp[count] = sh;
  //让计数器加1
  count++;
  
        x1 = x4;
        y1 = y4;}
 }
}
 
 

/*********3.定义一个shape类,保存坐标************/

package drawing;

public class Shape {

 //定义一个保存2点坐标的数组
 private int x1,x2,y1,y2;
 
 public Shape(int x1,int y1,int x2,int y2){
  this.x1 = x1;
  this.y1 = y1;
  this.x2 = x2;
  this.y2 = y2;
 }

 public int getX1() {
  return x1;
 }

 public void setX1(int x1) {
  this.x1 = x1;
 }

 public int getX2() {
  return x2;
 }

 public void setX2(int x2) {
  this.x2 = x2;
 }

 public int getY1() {
  return y1;
 }

 public void setY1(int y1) {
  this.y1 = y1;
 }

 public int getY2() {
  return y2;
 }

 public void setY2(int y2) {
  this.y2 = y2;
 }
 
 
}

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics