尼采般地抒情

尼采般地抒情

尼采般地抒情

音乐盒

站点信息

文章总数目: 321
已运行时间: 1782

java.util.Date


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

java.util.Random

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


java.util.Random 


javafx.geometry.Point2D

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

String和StringBuilder和StringBuffer


Object

toString()方法

equals()方法

默认实现的方法

public boolean equals(Object obj) {
    return (this == obj);
}

重写例子

public boolean equals(Object obj) {
    if (o instanceof Circe)
        return radius == ((Circle)o).radius;
    else
        return this == o;
}


























评论区

什么都不舍弃,什么也改变不了