Last active
December 25, 2015 06:09
-
-
Save erokhins/6930359 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Test { | |
private static class A { | |
private int bar; | |
private A() { | |
bar = 3; | |
System.out.println(getBar()); | |
} | |
public int getBar() { | |
return bar; | |
} | |
} | |
private static class B extends A { | |
private int bar = 4; | |
@Override | |
public int getBar() { | |
return bar; | |
} | |
} | |
public static void main(String[] args) { | |
new B(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open class A { | |
open val bar: Int | |
get() { | |
return $bar | |
} | |
{ | |
bar = 3 // $bar = 3 | |
println(bar) // virtual call getBar() | |
} | |
} | |
class B : A() { | |
override val bar = 4 // $bar = 4 | |
get() { | |
return $bar | |
} | |
} | |
fun main(args : Array<String>) { | |
B() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open class A { | |
open val bar: Int | |
{ | |
bar = 3 | |
println(bar) | |
} | |
} | |
class B : A() { | |
override val bar = 4 | |
} | |
fun main(args : Array<String>) { | |
B() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment