A linked list is a common basic data structure in Java, a linear table, but does not store data in a linear order, but rather as a pointer to the next node in each node. One algorithm that corresponds to linear is recursive algorithm: recursive algorithm is a direct or indirect process of invoking its own algorithm, often making the description of the algorithm concise and easy to understand.
Recursive algorithm is the use of self-invocation, and recursive algorithm must have an exit, too many recursion will also cause memory stack Overflow
1 public static int Jiegou (int num) { 2 if (Num==1 ) return 1 ; 4 1 ); // call yourself 5 6 }
There are 8 basic data types in Java, but in object-oriented, the principle of "everything is the object" in a design. The basic data types in Java do not conform to this idea at all. Because eight basic data types are not reference data types, in order to solve this problem, a wrapper class of eight data types is introduced.
The eight data type wrapper classes are divided into two types:
Number:integer, short, Long, Double, Float, Byte
Object:character, Boolean are direct subclasses of object
Basic data type:-----------wrapper class
int--------------Integer
Char------------Character
Float------------Float
Double---------Double
Boolean--------Boolean
BYTE-----------byte
Short----------Short
Long-----------Long
Since the introduction of packaging classes, then what is the role of packaging classes?
In a wrapper class, you can change a string to the specified base data type and use it when entering data:
(1), in the integer class, change the string to int type data
public static int parseint (String msg);
(2), in float class, change string to float type data
public static float parsefloat (String msg);
Note: The string must consist of a number in a transition operation, or an error will occur. Other types of data conversions in the same vein
String msg="$"; int m=parseint (msg); System. out . println (m); The result is: $
// caches a byte integer in an integer constant pool integer A=127; integer b=127; System. out. println (a==b); output is true
Package: The package is a class file classification management, to the class provides a multi-level namespace, the package is written in the first line of the program file, the name of the class is the name of the package. Class name, package is also considered a form of packaging.
Package and access modifiers: packages are managed for a Java source file, just like a file directory
Define a package: packages Com.vices.mihu;
Remember: The statement can only appear in the first sentence of the code.
Access modifiers:
Public: same class, same package, different bun class, different package non-subclass
Protected: Same class, same package, different bun category
Default: Same class, same package
Private: Same class
Summary: The package is accessed from the class between the packages, the classes in the package must be public, and the methods of the classes in the package must be public.
So how do I create a package?
In the Java environment, on the command line
Javac-d.packagedemo.java
Two errors are prone to occur:
1. No symbols found
Cause: The class name is wrong: calling a class in another package creates an object, and it must be clear that its package name is. Demo d=new Package.demo ();
2. Package does not exist
Cause: Is not found in the current directory, because the package is stored in a different directory, you should configure a Classpath
How do I use a package?
Import the package to use the files under the package
Import Package. Demo; The demo in the package was imported
Import Package. Demoa;
Import package.abc.*; All classes in the package have been imported
Guiding principle: which class to use, which class to import: The purpose of the guide package is to simplify the writing of the class name.
Java data structure of the chain list and packaging, package