static.Example of an internal class accessing an external classclass Outer {int num =3;class inner{int num =4;void Show () {int num = 5; SYSTEM.OUT.PRINTLN (num);//5system.out.println (This.num);//4system.out.println (Inner.this.num);// 4system.out.println (Outer.this.num);//3}}}class innerclass{public static void Main (String [] args) {Outer.Inner in =new Outer (). New Inner (); In.show ();}}Why does an inner class have direct access to members in an external class?Because the inner class hold
1, the difference between abstract class and interface:(1) An abstract class is a class that has only variables or method declarations, and these variables (attributes) and methods are abstract types. There is no implementation of the method for the abstract class.(2) An interface is a method declaration only. Without the implementation of a method, the method of an interface is also an abstract method, unlike an abstract class: an interface can only define static final member variables.2, abstr
Basic Theory:
-----------------------------------------------------
Java internal class: the definition of an internal class is defined within another class.
The reason is:
1. An internal class object can access the implementation of the object created for it, including private data. That is, an internal class instance is privileged to the instance of the class that contains it.
2. for other classes
class, Java provides special syntax, and typically is initialized with a constructor method.For example:StringBuffer s = new StringBuffer ();This initializes the StringBuffer object as an empty object.If you need to create a StringBuffer object with content, you can use:StringBuffer s = new StringBuffer ("abc");The content of this initialized StringBuffer object is the string "abc".It is important to note that StringBuffer and string are of different
=NewExternalclass (); Externalclass.innerclass Inner= extern.NewInnerclass (); Inner.output (The field of the method); }}classexternalclass{PrivateString s = "outer class field"; classinnerclass{PrivateString s = "Inner class field"; Public voidOutPut (String s) {System.out.println (The value of "s" is "+s); System.out.println (The value of "THIS.S" + This. s); System.out.println (The value of "EXTERNALCLASS.S" is "+ Externalclass". This. s); } } }View CodeOutput Result:The value of S is
We know that when writing each class, we need to test whether the class has errors. by writing a main () method in each class, we have a disadvantage, that is, the additional code that has been compiled must be carried with it. If this is troublesome for you, you can use Nested classes to place the test code.
/***** @ Author xiaanming **/public class innerclass {public void print (Object O) {system. out. println (O. tostring ();} public static class
(1) Introduction:
An inner class is actually a type of local data that is defined within a class declaration. (very similar to the struct node declaration), which differs from Java.
----internal class declarations have public and private points
If declared as public, it can also be used to define variables, such as Outer::inner var
If the declaration is private, then the outside can not be used to define variables, then Outer::inner var will cause co
public class Basetypeclasstest {/** Common class* 1, the basic type of encapsulation class: In the Java language, eight basic types correspond to a wrapper class.** Byte ====>>> byte* Short ===>>> Short* int =====>>> Integer* Long ====>>> Long** Float ===>>> Float* Double ===>> Double** Char ====>>> Character* Boolean ==>> Boolean** 2, in the Java language, for the basic type of data to provide the appropri
class to execute the extension function and the original class method.Compare the classes that are generated after the original class and the dynamic proxy:1, $Proxy 0 accesses the real class object through the Invocationhandler implementation class call.2, dynamic Proxy extension is not included in $proxy0, but rather callback Invocationhandler interface, implement invoke method extension through subclass.Before and after using dynamic proxies from
1. generalization (generalization) As I understand, generalization is the way that subclasses inherit the parent class, and they can extend their capabilitiesEg:extend Implements2. dependence (Dependency) For two relatively independent objects, when one object is responsible for constructing an instance of another object, or a service that relies on another object, the two objects are primarily dependent.As: local variables, parameters of methods, or calls to static methodsEg: you need a boat t
: JPanel and JScrollPane Java know how much (84) layout design of graphical interface Java know how much (85) text box and text area Java know how much (86) input and output of text box and text area Java know how much (87) Select boxes and radio buttons Java know how many (
drives or NAND flash. Read and write memory faster than read or write the hard disk or NAND flash files on the speed of a lot!Currently, files are mostly stored in bytes. So in the development, the use of Word throttling is more extensive.2 Comparison of IO classes for Java 1.0 and Java 1.1Table 01_java 1.0 and Java 1
In the previous article, we introduced how to manipulate the java byte code, and mentioned how to use the Java class loader to load the modified byte code and execute it on the JVM. Next, I will discuss the loading, linking, and initialization of Java classes. Java byte code
Modifiers in Java are categorized as class modifiers, variable modifiers, and method modifiers.Class modifier:1, Public:public is the public class.2. Package: The default defaults to pack modifiers, this package is visible.3. Abstract: A class that is decorated with an abstract modifier is called an abstract class. A class that contains one or more abstract methods must be declared as an abstract class, and an abstract class cannot be instantiated.4.
Original: http://blog.csdn.net/fatherican/article/details/44966891
The component thing is the noun, is the static part of the model.Behavioral things are dynamic parts that represent behavior.Grouped things are part of the organization.The annotation thing is the explanation part. Dependence: A change in one thing can cause another to change. Descriptive: Dashed + solid triangle or dashed + solid arrowAggregation: A special association that describes the combined relationship of a whole and a pa
In the absence of a good study of object-oriented
Design
Before the design pattern, I had a vague understanding of Java interfaces and Java Abstract classes.
When I first learned the Java language, it was hard to understand why the concept of interfaces was required. Although multi-inheritance can be imple
JAVA basics/Lesson 6: Object-oriented/JAVA classes and objects, Object-Oriented java
2013-0
I. process-oriented and object-oriented
1. process-oriented programming: Starting from every step of solving the problem, it is suitable for solving small and simple problems. Program = Algorithm + data.
2. object-Oriented Progr
A Java inner class or nested class is a class that is declared in a class or interface. We use an inner class to logically group classes and interfaces in one place so that it is more readable and maintainable. In addition, it can access members of external classes, including private data members and methods.Advantages of the Inner class:
Nested
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.