1 /*******************************************************************************
2 * Copyright (c) 2012-2013 University of Stuttgart.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * and the Apache License 2.0 which both accompany this distribution,
6 * and are available at http://www.eclipse.org/legal/epl-v10.html
7 * and http://www.apache.org/licenses/LICENSE-2.0
10 * Oliver Kopp - initial API and implementation
11 *******************************************************************************/
12 package org.eclipse.winery.librarytests;
14 * This class is intended to demonstrate static resolution of overloaded methods
16 * The output of this class is "Doing sth. with a followed by "Doing sth. with
17 * b" even if the passed "theObject" is of type B
19 public class InheritanceIllustration {
21 private static class A {
24 private static class B extends A {
27 private static class X {
29 public static void doSomething(A a) {
30 System.out.println("Doing sth. with a");
33 public static void doSomething(B b) {
34 System.out.println("Doing sth. with b");
42 public static void main(String[] args) {
43 A theObject = new B();
44 X.doSomething(theObject);
45 X.doSomething((B) theObject);