当前位置: 代码迷 >> J2SE >> java的max跟min的用法求教
  详细解决方案

java的max跟min的用法求教

热度:116   发布时间:2016-04-23 20:13:00.0
java的max和min的用法求教

                import java.lang.Math;
                double[] rec1 = new double[4];
double[] rec2 = new double[4];
double[] rec3 = new double[4];
                ..........省略.......
                rec3[3]=min(max(rec1[1],rec1[3]),max(rec2[1],rec3[3]));
rec3[4]=min(max(rec1[2],rec3[4]),max(rec2[2],rec2[4]));
rec3[1]=max(min(rec1[1],rec1[3]),min(rec2[1],rec2[3]));
rec3[2]=max(min(rec1[2],rec1[4]),min(rec2[2],rec2[4]));




然后提示错误
H:\Java>javac recMul.java
recMul.java:16: 错误: 找不到符号
                rec3[3]=min(max(rec1[1],rec1[3]),max(rec2[1],rec3[3]));
                            ^
  符号:   方法 max(double,double)
  位置: 类 recMul
recMul.java:16: 错误: 找不到符号
                rec3[3]=min(max(rec1[1],rec1[3]),max(rec2[1],rec3[3]));
                                                 ^
  符号:   方法 max(double,double)
  位置: 类 recMul
recMul.java:17: 错误: 找不到符号
                rec3[4]=min(max(rec1[2],rec3[4]),max(rec2[2],rec2[4]));
                            ^
  符号:   方法 max(double,double)
  位置: 类 recMul
recMul.java:17: 错误: 找不到符号
                rec3[4]=min(max(rec1[2],rec3[4]),max(rec2[2],rec2[4]));
                                                 ^
  符号:   方法 max(double,double)
  位置: 类 recMul
recMul.java:18: 错误: 找不到符号
                rec3[1]=max(min(rec1[1],rec1[3]),min(rec2[1],rec2[3]));
                            ^
  符号:   方法 min(double,double)
  位置: 类 recMul
recMul.java:18: 错误: 找不到符号
                rec3[1]=max(min(rec1[1],rec1[3]),min(rec2[1],rec2[3]));
                                                 ^
  符号:   方法 min(double,double)
  位置: 类 recMul
recMul.java:19: 错误: 找不到符号
                rec3[2]=max(min(rec1[2],rec1[4]),min(rec2[2],rec2[4]));
                            ^
  符号:   方法 min(double,double)
  位置: 类 recMul
recMul.java:19: 错误: 找不到符号
                rec3[2]=max(min(rec1[2],rec1[4]),min(rec2[2],rec2[4]));
                                                 ^
  符号:   方法 min(double,double)
  位置: 类 recMul
8 个错误


这是为什么呢,新手在线等。。不能这么嵌套写吗?
------解决思路----------------------
我那个擦 、数组越界了、最大索引是3、你哪能写个4
  相关解决方案