Q:
I have just found a static inner interface in our code-base.
- class Foo {
- public static interface Bar {
- /* snip */
- }
- /* snip */
- }
复制代码
I have never seen this before. The original developer is out of reach. Therefore I have to ask SO:
What are the semantics behind a static interface? What would change, if I remove the static? Why would anyone do this?
A:
An inner interface has to be static in order to be accessed. The interface isn't associated with instances of the class, but with the class itself, so it would be accessed with Foo.Bar, like so:
- public class Baz implements Foo.Bar {
- ...
- }
复制代码
In most ways, this isn't different from a static inner class.
分享到:
相关推荐
7. What is a Java package, and why is it used?Answer: A Java package is a namespace mechanism that organizes related classes and interfaces into modules. Packages help avoid naming conflicts, provide ...
Learn a use-case approach for developing Java enterprise applications in a continuously test-driven fashion. With this hands-on guide, authors and JBoss project leaders Andrew Lee Rubinger and Aslak ...
Put simply, the new features in Java 8 along with the (less-obvious) changes in Java 9 are the biggest change to Java in the 21 years since Java 1.0 was released. Nothing has been taken away, so all ...
1) what are static blocks and static initalizers in Java ? .......................................................... 9 2) How to call one constructor from the other constructor ? .......................
Fluent and clean Java interface for Google Static Maps API. > DEMO APK Why? Because using Google Play Services to show a Google Map may be overkill, or simply because Google Play Services are not ...
This report is for developers and architects interested in developing microservices and distributed applications. It does not explain the basics of distributed systems, but instead focuses on the ...
这篇测试题主要涵盖了小学六年级Module 2 Unit 4 "What would you like to be" 的核心内容,涉及了与职业相关的词汇、短语翻译以及选择题,旨在帮助学生理解和掌握与未来职业愿望和不同职业特点相关的基本英语知识。...
Inner Float: A Java float Reveals its Inner Nature The Floating Point Opcodes Circle of Squares: A Simulation On the CD-ROM The Resources Page 15 Objects and Arrays A Refresher on Objects and ...
Dex2jar is a good utility and smali2java is another good utility. You can use dex2jar or smali2java or both. Technical questions Does smali2java check smali syntax? All of syntax checks are based on...
Beginning Cryptography with Java While cryptography can still be a controversial topic in the programming community, Java has weathered that storm and provides a rich set of APIs that allow you, the ...
Chapter 6: Java Interview Questions – lastly, I have provided you with a comprehensive list of questions that you could be asked in an interview for a Java programming job. I also provide the answers...
More complex inline functions may also be put in a .h file for the convenience of the implementer and callers, though if this makes the .h file too unwieldy you can instead put that code in a ...
INTRODUCTION. 1 How to Use This Book. 1 Conventions Used in This Book....What You Don’t Have to Read....Foolish Assumptions....How This Book Is Organized ....Part 1: Getting ...The words in a Java program. 45
194、In a architecture pattern like MVC, it is mandatory that Servlet should be the controller, why not JSP? 46 195、Why JSP is used as View part of MVC ? 46 196、Can a database connection pool be ...
Pragmatic Unit Testing in Java 8 With JUnit steps you through all the important unit testing topics. If you've never written a unit test, you'll see screen shots from Eclipse, IntelliJ IDEA, and ...
scalable, distributed batch processing system using open-source frameworks Pro Spring Batch gives concrete examples of how each piece of functionality is used and why it would be used in a real-world...
Java As a Programming Platform 2 The Java “White Paper” Buzzwords 2 Java Applets and the Internet 7 A Short History of Java 9 Common Misconceptions about Java 11 Chapter 2: The Java ...
0.2 What Is a Computer? 0.3 Networks, the Internet, the World Wide Web 0.4 Why Study Programming? 0.5 Programming Languages 0.6 Why Study Java? 0.7 What Is Object-Oriented Programming?
How would you launch a video rental service in India? This book will teach you how to answer these questions and more., Cracking the PM Interview is a comprehensive book about landing a product ...