Created
September 5, 2017 06:51
-
-
Save praveenKajla/4e2e591556ced328c357c790d9a364c9 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
package readinglist | |
class DirectoryExplorer(val user:String){ | |
inner class PermissionCheck(){ | |
fun validatePermission(){ | |
} | |
} | |
fun listFolder(folder:String, user:String){ | |
val permissionCheck = PermissionCheck() | |
permissionCheck.validatePermission() | |
} | |
} | |
fun main(args: Array<String>) { | |
val dir = DirectoryExplorer() | |
val pc = DirectoryExplorer().PermissionCheck() | |
} |
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
package readinglist | |
class DirectoryExplorer(){ | |
class PermissionCheck(){ | |
fun validatePermission(user:String){ | |
} | |
} | |
fun listFolder(folder:String, user:String){ | |
val permissionCheck = PermissionCheck() | |
permissionCheck.validatePermission(user) | |
} | |
} | |
fun main(args: Array<String>) { | |
val dir = DirectoryExplorer() | |
val pc = DirectoryExplorer.PermissionCheck() | |
} | |
//kotlin allows me to access nested classes | |
//If i dont want to i can declare nested class as private | |
//we can access this nested class from java too | |
//DirectoryExplorer.PermissionCheck pc = new DirectoryExplorer.PermissionCheck() | |
//Now what if i want to access property of external class in nested class | |
//which is not possible by default . In order to do so define the nested class as | |
//a inner class | |
//but then i cant access nested class as DirectoryExplorer.PermissionCheck() | |
//since now nested class has becoome pasrt of the external class insatnce | |
//hence we would have to do DirectoryExplorer().PermissionCheck() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
//kotlin allows me to access nested classes
//If i dont want to i can declare nested class as private
//we can access this nested class from java too
//DirectoryExplorer.PermissionCheck pc = new DirectoryExplorer.PermissionCheck()
//Now what if i want to access property of external class in nested class
//which is not possible by default . In order to do so define the nested class as
//a inner class
//but then i cant access nested class as DirectoryExplorer.PermissionCheck()
//since now nested class has becoome pasrt of the external class insatnce
//hence we would have to do DirectoryExplorer().PermissionCheck()