Java Basics _ Inner classes: In Java, a class can be defined inside another class or inside a method, such that a class is called an inner class.The primary role of inner classes: using internal classes can reduce naming conflicts.Define location: An inner
) The first example of a programJava knows how many (7) classes and objectsJava know how much (8) class library and its organizational structureJava know how much (9) Import and Java class search pathJava know how much (10) data types and variablesJava know how much (11) data type conversionsJava know how many (12) ope
cannot new an instance of the enumeration value. This is perfectly reasonable, because we know that the enumeration value is a constant of publicstatic final.5. Implementing a specific interfaceWe already know that an enum can define variables and methods, and that it implements an interface as well as an interface to an ordinary class, and this is not an example
Java reflection Class -- class, java reflection -- Class
Let's first look at the functions provided by reflection:
The reflection mechanism provides the function to determine the data type, parse the class structure, and obtain in
First, ArraysFor the tool class for array manipulation, some methods for array sorting and binary searching are provided.Common methods:1. public static string toString (Int[] a): Converts an array of type int to a string.Converted to a string after the output form: ([element 1, Element 2, Element 3 ...]), arrays overrides the ToString method at the bottom.2, public static void sort (int[] a): Sorts the specified array of type int in ascending order o
the sine/cosine/tangent of a double type argumentTodegrees ()/toradians (): Return angle/radiansRandom (): Returns the stochastic numbertwo , Character class: The Character class is used to manipulate a single character, and the Character class wraps the value of a primitive type char in an object:CharCH ='a';//Unicode Character RepresentationCharUnichar ='\u03
following uses enumeration. Only three lines can replace the 21-29 lines of code.
1 // Student. java 2 package cn. itcast. enumeration3; 3 4 public class Student {5 private String name; 6 private Grade grade; // a B C D E 7 public String getName () {8 return name; 9} 10 public void setName (String name) {11 this. name = name; 12} 13 public Grade getGrade () {14 return grade; 15} 16 public void setGrade (Gr
Date classGets the system current time by default when creating an objectSimpleDateFormat classUsed to format the date; The creation object can be passed in the format: New SimpleDateFormat ("Yyyy-mm-dd hh:mm:ss"); Main method Format (date)Calendar classYou can use the Getcalendar () method in the SimpleDateFormat class to get the object. Common methods: Get (int); Common properties: Year MONTH ...Example:
return Color. Blue. Therefore, we need to note this when rewriting the toString method. For example, we should override the valueOf method. 6. Enum also provides the values method, which allows you to easily traverse all enumeration values. 7. enum also has an oridinal method. This method returns the order of the enumerated values in the enumerated classes. This
access external members only by name within the internal scope. The following is an example taken from Java Tutorial:
Public class ShadowTest {public int x = 0; class FirstLevel {public int x = 1; void methodInFirstLevel (int x) {System. out. println ("x =" + x); System. out. println ("this. x = "+ this. x); System. o
Basic Java syntax (1) ---- keywords Identifiers (Java language identifiers naming rules Java language package name, class name, Interface Name, variable name, function name, constant name naming rules), java basic syntax
I. Keywords
Keyword definition and features
Definiti
1. A Java program is a collection of classes.A class in a program has two kinds of arrangement structures.
For example: classenclosingclass{.....
Class anestedclass{......}
}
2. In some special cases, a class is also placed within the internal definition of another
();}Run the above code to get the following results:
Sun. misc. Launcher $ AppClassLoaderSun. misc. Launcher $ ExtClassLoader
From the above results, we can see that the top-level classloader obtains null. Why is it null? This class loader is written in c instead of a java class. The above relationship is verified.
In addition, this article introduces the appoi
class ' Demo { public static void Main (string[] args) { out.in in = new Out (). New in (); In.print (); or Access/ * out with sowing = new Out (); Out.in in = Out.new in (); In.print (); */ }}Run Result: 12From the above example, it is not difficult to see that the inner class actually seri
The Inner class(inner Class) defines the classes in the class. (generally Java's argument)The Nested class(nested Class) is a static (static) inner class. (generally C + + parlance)Static inner
pool. The following are the most popular formats for the field table:
Type
Name
Number
U2
Access_flags
1
U2
Name_index
1
U2
Description_index
1
U2
Attributes_count
1
Attribute_info
Attributes
Attributes_count
The access_flags is very similar to the access_flags in the class and is a modifier that rep
restricts access to the external classes. As an inner class of tools, the general access modifier is public or default. For ease of use, Java allows direct access to the members of the host class within the inner class (which also determines that you cannot directly new an inner
1. Design pattern: A problem-solving idea. The most effective way to solve a certain kind of problem. Java has 23 design patterns (summed up by predecessors).
Single-Example design pattern: Resolves a class that has only one object in memory.
if a class can always create only one instance, the
JAVA interface and abstract class, JAVA interface abstract class
For object-oriented programming, abstraction is one of its major features. In Java, OOP abstraction can be embodied in two forms: interfaces and abstract classes.
I. abstract
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.