background preloader

Java Coding Conventions

Java Coding Conventions

Why use inner classes in java Q: So what are inner classes good for anyway? A: Inner classes nest within other classes. A normal class is a direct member of a package, a top-level class. Inner classes, which became available with Java 1.1, come in four flavors: Static member classesMember classesLocal classesAnonymous classes Let's take a quick look at each in turn. Briefly, a static member class is a static member of a class. Like a static member class, a member class is also defined as a member of a class. Local classes are declared within a block of code and are visible only within that block, just as any other method variable. Finally, an anonymous class is a local class that has no name. To answer your specific question, I'll focus on the member and anonymous inner classes since those are the ones you'll likely encounter and use. The object-oriented advantage Let's look at the member class. An inner class allows us to remove that logic and place it into its own class. The organizational advantage Disadvantages?

Java class file History[edit] As of 2006[update], the modification of the class file format is being considered under Java Specification Request (JSR) 202.[1] File layout and structure[edit] Sections[edit] There are 10 basic sections to the Java Class File structure: Magic Number[edit] General layout[edit] Because the class file contains variable-sized items and does not also contain embedded file offsets (or pointers), it is typically parsed sequentially, from the first byte toward the end. Some of these fundamental types are then re-interpreted as higher-level values (such as strings or floating-point numbers), depending on context. Representation in a C-like programming language[edit] The constant pool[edit] The constant pool table is where most of the literal constant values are stored. Due to historic choices made during the file format development, the number of constants in the constant pool table is not actually the same as the constant pool count which precedes the table. See also[edit] Java bytecode

Related: