After some time in Java learning, you may often hear the word reflex, which means that Java has learned a higher level. Next, I'll take a step-by-step with you to uncover the mysteries of Java's advanced features reflection.The concept of the following class object is introduced first, and may often be used in this concept:
are freed, but the object allocated in the heap is not reclaimed, and the local variable lincintf in the main method points to it ;There's no problem here, but in line 27th, lincintf calls the test method, and the test method accesses the local variable A in the member method Localinclassre, and a does not exist at this time, so an error occurs;That is, local variables are different from the life cycle of the objects of local inner classes;To solve this problem,
Java File class learning notes 2: File class objects and common operation methods, file learning notes
1. File, relative path, and absolute path
1. File(1) standard files: such as images and music files.(2) directory file: a folder.(3) virtual memory files: temporary files generated by the system during program running.
2. File Path(1) Relative Path: compared wit
(); In.print (); }}4. Method inner Class (local inner Class) = = = "Understanding can be said to be infrequently usedMethod Inner class cannot be decorated with a restriction (such as public)Class out { private int: age = n; public void Print (final int ×) {
In Java, the StringTokenizer class separates strings, and the string class separates strings.
This class is rarely used and is not recommended in the API documentation. RecommendedStringOfSplitMethod or java. util. regex package.
import java.util.StringTokenizer;public
does not define final, then when the outer class method executes, The local variable must be gc, but a method of the inner class has not been executed, and the external variable that he refers to cannot be found. If defined as final,java, this variable is copied as a member variable inside the inner class, so that the
[JAVA] java enumeration class, java Enumeration
I. Under what circumstances do I use enumeration classes?
Sometimes the objects of a class are limited and fixed. In this case, it is more convenient to use enumeration classes?
2. Why not use static constants to replace enumer
{private String name = "Zhang San";p rivate int num1 = 1;public void outer () {System.out.println (name+ "" +num1);//syst Em.out.println (num2); The outer class cannot directly access the Inner class member Inner1 Inner1 = new Inner1 ();//The outer class can instantiate an inner class, access the Inner
1. Class LoaderMultiple ClassLoader can be installed in a Java virtual machine, and the system defaults to the main three classloader, each of which is responsible for loading the class at a particular location: BootStrap (embedded in the Java virtual machine, written in C + +), Extclassloader,appclassloader. Of course
The inner class of the member means that the bread in an outer class has a non-static class, for example:class outerclass{ // variables, function definitions ... class innerclass { // variable, function definition ... }} About the various uses of the members ' i
* @param x * @return */public static byte inttobyte (int x) {return (byte) x; }/** * byte to int * @param b * @return */public static int Bytetoint (byte b) {//java byt E is signed, converted to unsigned return B 0xFF via 0xff; }/** * byte[] to int * @param b * @return */public static int bytearraytoint (byte[] b) { Return b[3] 0xFF | (B[2] 0xFF) The most comprehensive
[Java class set] _ identityhashmap class notes
In normal map operations, the key itself cannot be repeated.
Import Java. util. map; import Java. util. hashmap; import Java. util. iterator; import
total instance object of classSystem.out.println (c1==C2); //The Third Way of expressionClass c3=NULL; Try{C3=class.forname ("Com.reflect.Foo"); } Catch(ClassNotFoundException e) {e.printstacktrace (); } System.out.println (C2==C3); //We can create instance objects of the class--> by the class type of the class, by creating an instance of Foo by C1 or C2 or C3.
start is called, non-final variables will disappear, and the internal class reference will be invalid!
Practice: The behavior of the java compiler is as follows (the precondition is that the variable is referenced in the internal class ):If it is defined as final, the java compiler will generate a copy of an external
type, for example, we can invoke Getprimitive7ype and set Primitive7ype on a Field object, where Primitive7ype is the basic type name (first-letter uppercase). The Get method can be used for the following statement:
Short Value=field.getshort (o);
The set method can be used for the following statement:
Field.setshort (O, NV);
You can avoid using wrapper class objects in statements declared in both of these ways.
The field
to the same object is true, only two objects that have a parent-child or peer relationship can be compared1System.out.println (NewInteger (1). Equals (NewInteger (1)));//true2 //because the integer compares the value, the integer class overrides the Equals method of the parent class of the object class3 //the method of the integer class aft
JAVA basics: Find the class name-general Linux technology-Linux programming and kernel information from the. class file. The following is a detailed description. You can determine the name of a class in multiple ways:
Assume that all classes start with com, org, or net.
Search for a
in the interface
Interface is a way to implement multiple inheritance in Java
Interfaces are public-decorated, and methods are public
/*声明一个接口*/publicinterface Runner { publicvoidrun();}/*实现接口*/publicclass implements Runner { publicvoidrun() { System.out.printf("我会跑!"); }}Inner classIn Java, one class is allowed to define another
Java inheritanceInheritance is the child class inherits the characteristics and behavior of the parent class, so that the subclass object (instance) has the parent class's instance domain and method, or the subclass inherits the method from the parent class, so that the subclass has the same behavior as the parent clas
manipulating arrays in Java using the Arrays class
The Arrays class is a tool class provided in Java in the Java.util package. The class contains methods for manipulating arrays directly, such as sorting and searching directly, a
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.