package com.newer.test;import java.util.*;public  class FahrenheitToCelsius extends Conversion{
private int fahrenhei;

public FahrenheitToCelsius(){

}
Scanner sc = new Scanner(System.in);   //错误在这个分号上面,搞不懂了

this.fahrenhei = sc.nextInt();
public double convert(){
return (fahrenhei - 32) * 5 / 9.0; // 摄氏温度=(华氏温度-32)*5/9。
}
}
—————————————————————————————————————————package com.newer.test;public abstract class Conversion {

public abstract double convert();
}——————————————————
报这个错误
//Multiple ers at this line
// - Watchpoint:FahrenheitToCelsius [access and modification] - sc
// - Syntax error on token ";", invalid AssignmentOperator

解决方案 »

  1.   

    感觉楼主的本意应该是这样的吧!
    public class FahrenheitToCelsius extends Conversion {
    private int fahrenhei; public FahrenheitToCelsius() {
    Scanner sc = new Scanner(System.in);//错误在这个分号上面,搞不懂了
    this.fahrenhei = sc.nextInt();
    } public double convert(){
    return (fahrenhei - 32) * 5 / 9.0;  // 摄氏温度=(华氏温度-32)*5/9。
    }
    }
    this.fahrenhei = sc.nextInt();
    其实是这一行放的位置不对。
      

  2.   

    Scanner sc = new Scanner(System.in);   //错误在这个分号上面,搞不懂了this.fahrenhei = sc.nextInt();
    我只想知道为什么这样写会报错
      

  3.   

    类里只能定义变量,方法,或者 {}括起来的代码块。
    不能出现执行语句的。this.fahrenhei = sc.nextInt();
    这是一条执行语句,它应该在一个方法里,或在{}括起来的代码块里,而楼主直接在类里,所以报错。
    照一楼可以的。