05类
##1
public int sum(double...values)
//接受若干个,最后一个为valus
##2
//构造器条件判断
if(x > 0&& y > 0&&z > 0&&p > 0)
else
##3
/数字转化成字符串后返回
double area=this.width*this.height;
return String.format("%.2f", area);
##4最大公约数
//比较绝对值
public int gys(int a, int b)
{
int n = Math.min(Math.abs(a), Math.abs(b));
int m = Math.max(Math.abs(a), Math.abs(b));
int t;
while(n != 0)
{
t = m % n;
m = n;
n = t;
}
return m;
}
##5重写toString
@Override
public String toString() {
return "("+x+","+y+")";
}
##5
return new Point(x, y);
//多个值需要通过类或数组返回
Point p = new Point(cin.nextInt(), cin.nextInt());
//可以直接这样输入赋值合并
##6
double A=radius*radius*Math.PI;
return (float)((Math.round(A * 100)) / 100.0);
##7
//字符串转化为字符数组
String str=sc.next();
char[] ch=str.toCharArray();
标签:return,函数,##,编程,int,abs,考试,Math,String
From: https://www.cnblogs.com/hoshino-/p/18491445