Answers for "java.lang.StackOverflowError:"

0

java.lang.StackOverflowError

public class Vehicle {
    public void accelerate(float acceleration, float maxVelocity) {
        // set the acceleration
    }
}

public class SpaceShip extends Vehicle {
    @Override
    public void accelerate(float acceleration, float maxVelocity) {
        // update the flux capacitor and call super.accelerate
        // oops meant to call super.accelerate(acceleration, maxVelocity);
        // but accidentally wrote this instead. A StackOverflow is in our future.
        this.accelerate(acceleration, maxVelocity); 
    }
}
Posted by: Guest on February-25-2021
0

java stackoverflowerror

public class StackOverflowErrorExample {

  public static void recursivePrint(int num) {
    System.out.println("Number: " + num);
    if (num == 0)
      return;
    else
      recursivePrint(++num);
  }

    public static void main(String[] args) {
      StackOverflowErrorExample.recursivePrint(1);
    }
}
Posted by: Guest on May-31-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language