大哥,
写public interface Index吧。
如果你的Index是写在一个单独的文件中的。

解决方案 »

  1.   

    我的Index不是在一个单独的文件啊,//: Geshan.java
    // computing everything about Filter.
    package Geshan;
    import java.io.*;
    import java.text.DecimalFormat;interface Index{
      double second=86400;//每天的秒数
      double K=1000;
      double smallK=0.001;
      double dushu=180;//PI的度数
      double g=9.81;//重力加速度
      
      double averageVolume=20000.0/second;//立方米/秒,平均流量
      double kTotal=2.7/(Math.pow(averageVolume*K,0.11));//无单位,总变化系数  double velocity=0.9;//米/秒,过栅流速
      double e=20;//毫米,栅条间隙
      double alpha=60;//度,格栅安装倾角
      double k=3;//系数,格栅受污物堵塞后,水头损失增大的倍数
      double beita=2.42;//用来计算jita(阻力系数),当为矩形断面时,为2.42
      double s=0.01;//米,栅条宽度
      double jita=beita*Math.pow((s/(e*smallK)),(4/3.0));//阻力系数
      double h2=0.3;//米,栅前渠道超高
      double alpha1=20;//度,进水渠展开角
      double w1=0.07;//立方米/千立方米污水,栅渣量
      double B1=0.65;//进水渠宽
      double height=0.4;//米,栅前水深
      double l11=1;//渠道的一段长度
      double l12=0.5;//渠道的另一段长度
    }
      public class Geshan  {
        
        public static String formatNum(double f){
            DecimalFormat  df=new DecimalFormat("0.00#");
            return df.format(f);
          }
      public static void main(String[] args){
          Geshan geshan=new Geshan();      //计算栅条的间隙数
          double n=Math.ceil(Index.averageVolume*Index.kTotal
                 *Math.sqrt(Math.sin(Index.alpha*Math.PI/Index.dushu))/
                 (Index.e*Index.smallK*Index.height*Index.velocity));
                       
          //计算栅槽宽度
          double B=Index.s*(n-1)+Index.e*Index.smallK*n;
          //计算进水渠渐宽部分长度
          double l1=(B-Index.B1)/(2*Math.tan(Index.alpha1*Math.PI/Index.dushu));
          //进水渠道内的流速
          double v1=Index.averageVolume*Index.kTotal/(Index.height*Index.B1);
          //栅槽与出水渠道连接处的渐窄部分长度:
          double l2=l1/2.0;
          //过栅水头损失
          double h1=Index.jita*
                    Index.velocity*Index.velocity/(2*Index.g)*
                     Math.sin(Index.alpha*Math.PI/Index.dushu)*Index.k;
                    
          //栅后槽总高度
          double H=Index.height+h1+Index.h2;
          //栅槽总长度
          double L=l1+l2+Index.l11+Index.l12+(Index.height+Index.h2)/
                       Math.tan(Index.alpha*Math.PI/Index.dushu);
          //每日栅渣量
          double W=Index.averageVolume*Index.kTotal*
                   Index.w1*Index.second/(Index.kTotal*Index.K);      
                     
          
          try {
          DataOutputStream out2 =
            new DataOutputStream(
              new BufferedOutputStream(
                new FileOutputStream("Data.txt")));
          out2.writeDouble(n);
          out2.writeDouble(B);
          out2.writeDouble(l1);
          out2.writeDouble(v1);
          out2.writeDouble(l2);
          out2.writeDouble(h1);
          out2.writeDouble(H);
          out2.writeDouble(L);
          out2.writeDouble(W);
          out2.writeDouble(Index.kTotal);
          out2.close();
          DataInputStream in5 =
            new DataInputStream(
              new BufferedInputStream(
                new FileInputStream("Data.txt")));
          
          // Must use DataInputStream for data:
          System.out.println("n="+formatNum(in5.readDouble()));
          System.out.println("B="+formatNum(in5.readDouble()));
          System.out.println("l1="+formatNum(in5.readDouble()));
          System.out.println("v1="+formatNum(in5.readDouble()));
          System.out.println("l2="+formatNum(in5.readDouble()));
          System.out.println("h1="+formatNum(in5.readDouble()));
          System.out.println("H="+formatNum(in5.readDouble()));
          System.out.println("L="+formatNum(in5.readDouble()));
          System.out.println("W="+formatNum(in5.readDouble()));
          System.out.println("kTotal="+formatNum(in5.readDouble()));
        } catch(EOFException e) {
          System.out.println("End of stream");
        }    // 6. Reading/writing random access files
    /*     try{
     RandomAccessFile rf =
          new RandomAccessFile("rtest.txt", "rw");
        for(int i = 0; i < 10; i++)
          rf.writeDouble(i*1.414);
        rf.close();    rf =
          new RandomAccessFile("rtest.txt", "rw");
        rf.seek(5*8);
        rf.writeDouble(47.0001);
        rf.close();    rf =
          new RandomAccessFile("rtest.txt", "r");
        for(int i = 0; i < 10; i++)
          System.out.println(
            "Value " + i + ": " +
            rf.readDouble());
        rf.close();*/
    /*    }catch(FileNotFoundExcepton e){
         System.out.println("File Not Found:");*/
        catch(IOException e){
         System.out.println("IOException!");
        }
      }
    }///~
        
      

  2.   

    你尝试把index放到一个单独文件中设为public的,
    里面的成员设为public static的再试试?
      

  3.   

    我设了一个单独的文件
    已经成功了
    但你能告诉我
    为什么在这里面interface 不可设为public
    而单独的一个文件中就可以了呢??