Programming
My notes.
Interfacesinner classes provides a more sophisticated way of organizing and controlling the objects in your system.
Interface is better than abstract class, because we can write a class that "can be upcasting to multiple base classes" to achieve multiple inheritance in C + +.
You can add the keyword public before the keyword interface (but only if the interface is defined as a fil
particular, if the constructor of the internal class has no parameter, public Inner getInner () {return new Inner ();} public class Inner {public void print (String str) {System. out. println (str );}}}
2. Local internal class
A local internal class is defined in the method and scope. Use outer. this to indicate the
Tips"Effective Java, third Edition" an English version has been published, the second edition of this book presumably many people have read, known as one of the four major Java books, but the second edition of 2009 published, to now nearly 8 years, but with Java 6, 7, 8, and even 9 of the release, the Java language has
);Setcontentview (R.layout.activity_main);Intent Intent = new Intent (mainactivity.this, Otheractivity.class);}}This shows that the intent object we created is associated with an object of type mainactivity, which means that the intent is emitted by the Mainactivity object,Well, this shows that there are cases where the class name is used. This is not the same as the direct use of this, but the class name i
1, the definition of the inner class:An inner class can be defined in another class and can be defined in a function or even as part of an expression.2, the classification of the Inner class:The inner classes in Java are divided into four types:member Inner class member inner classLocal internal
is followed by a curly brace, which is the anonymous inner class defined within the curly braces.Instance CodeTest classImport Javax.swing.joptionpane;public class Test {public static void main (string[] args) {Talkingclock c = new Talkingclock (); C.start (+, true); Joptionpane.showmessagedialog (null, "Quit?") "); System.exit (0);}}function ClassImport Java.aw
Two keywords extends: Generally the inheritance class, which cannot be inherited multiple times in java. Implements: generally refers to the implementation interface. Because java does not support multiple inheritance, an interface is used to implement a function similar to multiple inheritance. Example: [java]
The Java inner class learns fromThe idea of Java programmingOverview
What is an internal class?Thinking in Java is defined so that the definition of a class is placed inside the definition of another
type in the method.4). Anonymous Inner class:Example:Class anonymousclass{@SuppressWarnings ("deprecation") public void print (Date data) { System.out.println ( Data.tolocalestring ());}} public class Anonymousclasstest {public static void main (string[] args) {Anonymousclass a = new Anonymousclass (); an.print (new date ()); An.print (new Date () {@Override @deprecatedpublic String tolocalestring
Java internal class, I look at "Thinking in Java" When always feel ambiguous, struggled for several days, feel a part of the problem to think clearly, write an essay record, for later modification and reviewWhat is an internal class?The inner class is a
) method 1. Do you have any restrictions?2) method 2 gets the call stack through the exception mechanism, with the worst performance, but can provide functions not available for other methods, as well as the method name and row number; however, this is not a common practice;3) method 3 is just a brief analysis of the name of the anonymous class. Obviously, it is much simpler. In fact, the performance is als
= System.currenttimemillis ();//Test Start Time9Callback.execute ();// Perform callback operations Ten LongEnd = System.currenttimemillis ();//Test End Time OneSystem.out.println ("[Use time]:" + (End-begin));//Print usage Time A } - - Public Static voidMain (string[] args) { theTools tool =NewTools (); -Tool.testtime (NewCallBack () { - //defining the Execute method - Public voidExecute () { + //Here you can add one or more
1. IdentifiersIdentifier: Used to represent the class name, variable name, method name, array name, valid character sequence of file nameIdentifiers by any order of letters, underscores such as: Name, User_age, $page identifier characters cannot be numeric identifiers cannot be reserved keywords in Java2. KeywordsHow many Java keywords (keyword) are there?51+2 a reserved word = 53 Keywords (
* Curriculum review:* CSS* Introduction to CSS* Cascading Style sheets.* CSS and HTML combination (4 kinds)* HTML Tag provides property style= "CSS Code"* HTML provides tags * Introduction of external documents@import URL ("Address of the CSS file"); write in the middle of the * Via HTML tags * Priority: From top to bottom in general, from outside to inside, priority from low to high.Special Case Tag Selector * CSS Selector* Basic Selector* Tag name Selector* Div{css}*
inner class (a class that exists inside a method), ④ anonymous inner class (which exists inside a class). But class with no class name).Super keywordThis is a pair, very similar in usa
, Static inner class, Anonymous inner classmember Inner class: exists as a member of an external class, and is parallel to the properties, methods of the outer classLocal inner class: A class defined inside a method body of an out
static and the display is null.
In java, what is the higher priority of local variables when they have the same name? It is better to give a simple example,
Public class test (){Public static void main (string [] args ){Int I = 3;System. out. println (I );}Public void face (){For (int I = 0; I System. out. println (I );}}}The result is 1 to 5. When two variables are named again, the priority of local vari
= new StringLengthComparator(); public int compare(String s1, String s2) { return s1.length() - s2.length(); }}A reference to a specific policy can be said to be a function pointer.The abstraction of a specific strategy becomes a policy interface (strategy interface).For the example above, there is a comparator in java.util:public interface ComparableAs a result, we may use anonymous classes to pass a specific policy when we are using it
Three basic annotations for Java@Deprecated: Marks this program element as obsolete, usually because it is dangerous or has a better choice.@SuppressWarnings: Suppress the specified compiler warning.@Override: Represents a method declaration that intends to override another method declaration in a superclass. If the method uses this annotation type for annotations but does not override the superclass method, the compiler generates an error message.Met
file every time.
Scenario Three: Tomcat uses WebappClassLoader to load separately, not load and then delegate the parent loader to load.
Appendix
Fully qualified name of class: The absolute path of the class can be understood, the general rule is the package name. External class Name $ internal
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.