Hi, can anyone tell me how to access the inner interface (bar)...?
When i compile both i got an error: TestFoo.java:6: cannot resolve symbol symbol : variable MY_CONST location: class java.lang.String System.out.println("Const= " + foo.bar.MY_CONST); ^ 1 error So how can i access the inner interface??? Thanks in advance and regards Dirk (edited by Cindy to format code using [ code] and [ /code] tags without the spaces) [ August 28, 2003: Message edited by: Cindy Glass ]
Hi Cindy, thanks for your quick reply. What wonders me is that, if i comment the line public static final String bar = "Class const"; out, it works fine. I can access the interfaces constant without implementing the interface.... Regards Dirk
i.e., use an empty, anonymous implementation. Otherwise, if this came up in a real program, I think the solution is that you're going to have to rename something. Even if there was a non-obvious way to access the interface constant directly, do you really want to write code that requires alien super-genius to interpret? I think it was Steve Maguire in "Writing Solid Code" who said that if you ever find yourself writing code and you say to yourself 'Wow, I'm clever!', immediately delete the code and rewrite it in a more straightforward way. The maintenence programmer who comes after you isn't going to be as impressed by your code as you are.