小编for*_*son的帖子

公共课的非法表达开始

我正在尝试编写一个利用java的Abstract类特性的程序.第63行我得到了一个"非法的表达式开始"错误,它声明了公共类AbstractCar.任何人都可以解释为什么我收到此错误以及如何纠正它.先感谢您

public class AbstractCar {
  public static final void main(String args[]) {

    abstract class Vehicle {
      //subclasses will inherit an attribute
      int maxSpeed;
      //subclasses must implement this method 
      //(otherwise they have to be declared as abstract classes)
      abstract void showMaxSpeed();
      //subclass will have this method (through inheritance) as is (default implementation)
      //or they may implement their own implementation (override a method)
      int getWheelsNumber() {
        return 4;
      }
    }

    /**Car IS-A Vehicle*/
    class Car extends Vehicle {
      public Car() {
        maxSpeed …
Run Code Online (Sandbox Code Playgroud)

java

-2
推荐指数
1
解决办法
935
查看次数

为什么StringWriter中的方法`close`,PrintWriter没有效果?

为什么在这个类(StringWriter,PrintWriter)方法close中没有像javadoc中提到的那样有效?

据我所知,简单的没有实现.但为什么?

java

-2
推荐指数
1
解决办法
784
查看次数

我的if/else语句中的'else'永远不会发生 - 有人可以解释为什么吗?

只是执行codecademy课程,当我运行代码时,一切都有效,除了这个if/else语句.当它到达那个时,无论我为userAnswer提示输入什么,我只是得到'if'输出.有人可以解释原因吗?一直在读这个东西100x,答案不是跳出来的.万分感谢.

var userAnswer = prompt("Do you want to race Bieber on stage?");

if(userAnswer="yes") {

    console.log("You and Bieber start racing. It's neck and neck! You win by a shoelace!")

} else {

    console.log("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'")

}
Run Code Online (Sandbox Code Playgroud)

javascript

-5
推荐指数
1
解决办法
119
查看次数

标签 统计

java ×2

javascript ×1