Skip to main content
5 events
when toggle format what by license comment
Jul 28, 2020 at 10:55 comment added Kimutai Thanks. I like your answer
Jul 28, 2020 at 10:54 vote accept Kimutai
Jul 28, 2020 at 10:34 comment added Marc Down-casting is the only option with the example I provided, but there are other approaches. For example the class java.io.File has a method list() that returns null if invoked on a non directory. My point was to show how to separate and hide the state into classes but you can adjust the Inode interface.
Jul 28, 2020 at 10:12 comment added Kimutai thanks for the feedback. So on the point you make about putting regular files and directories into separate classes, when listing them using ls Inode objects are returned and we can use the isDirectory() method to determine whether they are files are not. So suppose they are directories and I want to list the contents of the directories, is down-casting the Inode object into a Directory object a good idea in this case?
Jul 28, 2020 at 8:01 history answered Marc CC BY-SA 4.0