repl.it
@kenanhancer/

PolymorphismDemo6

Java

No description

fork
loading
Files
  • Main.java
  • jdt.ls-java-project
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class Main {
  public static void main(String[] args) {
    Calculator calc = new Calculator();

    int r1 = calc.add(5, 4);

    int r2 = calc.add(7, 8, 20);

    System.out.println(r1);

    System.out.println(r2);
  }
}

class Calculator {
  public int add(int a, int b) {
    return a + b;
  }

  public int add(int a, int b, int c) {
    return a + b + c;
  }
}
?