java.util.Date

  1. java.util.Date date = new java.util.Date();
  2. System.out.println(date.toString());
  1. Sun Mar 09 13:50:19 EST 2020

java.util.Random

Math.Random():Math类里面的随机数函数,范围是0.0到0.1

java.util.Random

image.png

javafx.geometry.Point2D

image.png

  1. import java.util.Scanner;
  2. import javafx.geometry.Point2D;
  3. public class TestPoint2D {
  4. public static void main(String[] args){
  5. Scanner input= new Scanner(System.in);
  6. System.out.println("Enter point1's x-,y-coordinates:");
  7. double x1=input.nextDouble();
  8. double y1=input.nextDouble();
  9. System.out.println("Enter point2's x-,y-coordinates:");
  10. double x2=input.nextDouble();
  11. double y2=input.nextDouble();
  12. Point2D p1 =new Point2D(x1,y1);
  13. Point2D p2 =new Point2D(x2,y2);
  14. System.out.println("p1 is"+p1.toString());
  15. System.out.println("p2 is"+p2.toString());
  16. System.out.println("distance is"+p1.distance(p2));
  17. }
  18. }
  1. Enter point1's x-,y-coordinates:
  2. 1 2
  3. Enter point2's x-,y-coordinates:
  4. 3 4
  5. p1 isPoint2D [x = 1.0, y = 2.0]
  6. p2 isPoint2D [x = 3.0, y = 4.0]
  7. distance is2.8284271247461903

String和StringBuilder和StringBuffer

Object

toString()方法

equals()方法

默认实现的方法

  1. public boolean equals(Object obj) {
  2. return (this == obj);
  3. }

重写例子

  1. public boolean equals(Object obj) {
  2. if (o instanceof Circe)
  3. return radius == ((Circle)o).radius;
  4. else
  5. return this == o;
  6. }