abstract class Bench
{
abstract void bench(); public long repeat (int count)
{
long start = System.currentTimemills();
for (int i=0;i<count ;i++ )
{
bench();
}
return (System.currentTimeMills()-start);
}
class MethodBench extends Bench
{
void  bench()
{

}
public void start (String[] args)
{
int count =Integer parseInt(args[0]);
long time=new Method Bench().repeat(count);
System.out.print(count + "methods in"+ time+"milliseconds");
}
}
---------- javac ----------
E:\MethodBench.java:24: ';' expected
int count =Integer parseInt(args[0]);
                                   ^
E:\MethodBench.java:25: '(' or '[' expected
long time=new Method Bench().repeat(count);
                                     ^
E:\MethodBench.java:29: '}' expected
^
3 errors输出完成 (耗时 0 秒) - 正常终止

解决方案 »

  1.   

    int count =Integer parseInt(args[0]);
    Integer的后面少了个“.”,改成:int count =Integer.parseInt(args[0]);long time=new Method Bench().repeat(count);
    Method和Bench()之间多了个空格,改成:long time=new MethodBench().repeat(count);E:\MethodBench.java:29: '}' expected
    类Bench少了一个“}”,如果按照你的程序缩进,是repeat方法对应的“}”忘了敲了。
      

  2.   

    abstract class Bench
    {
    abstract void bench(); public long repeat (int count)
    {
    long start = System.currentTimemills();
    for (int i=0;i<count ;i++ )
    {
    bench();
    }
    return (System.currentTimeMills()-start);
              }
    }
      

  3.   

    class MethodBench extends Bench
    {
    void  bench()
    {

    }
    public void start (String[] args)
    {
    int count =Integer parseInt(args[0]);
    long time=new Method Bench().repeat(count);
    System.out.print(count + "methods in"+ time+"milliseconds");
    }
    }
      

  4.   

    是不是还加头文件啊?
    ---------- javac ----------
    E:\MethodBench.java:8: cannot find symbol
    symbol  : method currentTimemills()
    location: class java.lang.System
    long start = System.currentTimemills();
                                       ^
    E:\MethodBench.java:13: cannot find symbol
    symbol  : method currentTimeMills()
    location: class java.lang.System
    return (System.currentTimeMills()-start);
                                  ^
    2 errors输出完成 (耗时 0 秒) - 正常终止
      

  5.   

    abstract class Bench
    {
    abstract void bench(); public long repeat (int count)
    {
                        
    long start = System.currentTimeMillis();
    for (int i=0;i<count ;i++ )
    {
    bench();
    }
    return (System.currentTimeMillis()-start);
         }
    }
    class MethodBench extends Bench
    {
    void  bench()
    {

    }
    public static void main(String[] args)
    {
    int count =Integer.parseInt(args[0]);
    long time=new MethodBench().repeat(count);
    System.out.print(count + "methods in"+ time+"milliseconds");
    }
    }
    请楼主看准那些方法的名称
      

  6.   

    我刚学。。是不是加import java.lang.*;
    可还不对。
      

  7.   

    ---------- javac ----------
    E:\MethodBench.java:8: cannot find symbol
    symbol  : method currentTimemills()
    location: class java.lang.System
    long start = System.currentTimemills();
                                       ^
    E:\MethodBench.java:13: cannot find symbol
    symbol  : method currentTimeMills()
    location: class java.lang.System
    return (System.currentTimeMills()-start);
                                  ^
    2 errors输出完成 (耗时 0 秒) - 正常终止
      

  8.   

    应该是   System.currentTimeMillis()
    第8行打成了     currentTimemills
    第13行          currentTimeMills
      

  9.   

    我想调用start()
    却有错误。class MethodBench extends Bench
    {
    void  bench()
    {

    }
    public void start (String[] args)
    {
    int count =Integer.parseInt(args[0]);
    long time=new MethodBench().repeat(count);
    System.out.print(count + "methods in"+ time+"milliseconds");
    } public static void main(String args[])

    MethodBench m=new MethodBench();
    m.start();
    }}---------- javac ----------
    E:\MethodBench.java:34: start(java.lang.String[]) in MethodBench cannot be applied to ()
    m.start();
                     ^
    1 error输出完成 (耗时 0 秒) - 正常终止
      

  10.   

    成这样编译对了。改可结果值得怀疑吧?
    class MethodBench extends Bench
    {
    void  bench()
    {

    }
    public void start (String[] args)
    {
    int count =Integer.parseInt(args[0]);
    long time=new MethodBench().repeat(count);
    System.out.print(count + "methods in"+ time+"milliseconds");
    } public static void main(String[] args)
    {
     String[] arg={"jdfk","kfdj"};
     
    MethodBench m=new MethodBench();
    m.start(arg);
    }}---------- java ----------
    Exception in thread "main" java.lang.NumberFormatException: For input string: "jdfk"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
    at java.lang.Integer.parseInt(Integer.java:447)
    at java.lang.Integer.parseInt(Integer.java:497)
    at MethodBench.start(MethodBench.java:26)
    at MethodBench.main(MethodBench.java:36)输出完成 (耗时 0 秒) - 正常终止
      

  11.   

    String[]arg={"jdfk","kfdj"};
    i不是要数字的吗?
     String[]arg={"100","200"};
      

  12.   

    标准的代码请楼主看下面的:
    abstract class Bench
    {
    abstract void bench();
    public long repeat (int count)
    {
    long start =System.currentTimeMillis();
    for (int i=0;i<count ;i++ )
    {
    bench();
    }
    return (System.currentTimeMillis()-start);
    }
    }
    public class MethodBench extends Bench
    {
    void  bench(){}
    public static void main (String[] args)
    {
    int count =Integer.parseInt(args[1]);
    long time=new MethodBench().repeat(count);
    System.out.print(count + "methods in"+ time+"milliseconds");
    }
    }
      

  13.   

    我又改成这样,可怎样能让count的值输出?我附了枝却还是0;abstract class Bench
    {
    abstract void bench();
    //private int count1=7;
    public long repeat (int count)
    {
    //count=count1;
    long start = System.currentTimeMillis();
    for (int i=0;i<count ;i++ )
    {
    bench();
    }
    return (System.currentTimeMillis()-start); }
    }class MethodBench extends Bench
    {
    void  bench()
    {

    }
    public void start (String[] args)
    {
    int count =Integer.parseInt(args[0]);
    long time=new MethodBench().repeat(7);
    System.out.print(count + " methods in "+ time+"milliseconds");
    } public static void main(String[] args)
    {
     String[] arg={"5","90"};
     
    MethodBench m=new MethodBench();
    m.start(arg);
    }}