Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Introduction of JDK 1.4 in JSP page
Introduction of JDK 1.4 in JSP page
Chapter 1 Java Foundation

1.Java common sense

1.Java is an object-oriented programming language developed by sun Company in 1995.

2.Java is a robust language, which has nothing to do with the platform and is closely integrated with the Internet.

3.Java is mainly used in network servers, relational databases, mainframe computers, telephones, mobile communications and games.

4.Java became popular because it can run on the World Wide Web. It downloads Java programs from web pages through browsers and runs them locally, which is called applets.

5.Java's version:

Java 1.0: 1995, a small version with Web as the core, runs in a Web browser.

Java1.1:1997 is introduced, the user interface is improved, and the event handling and JavaBean component technology are rewritten.

Java2: 1998 with SDK 1.2 is introduced, and the graphical user interface function and database connection are rewritten.

Java 2: with SDK 1.3 was launched in 2000, which improved the multimedia function and accelerated the compilation speed.

In 2002, Java 2: with SDK 1.4 was introduced, which improved security, supported COBRA, bundled Java Web Start technology, had powerful Java plug-ins and supported Unicode3.0.

6.C/C++ language compiles and generates machine code for a specific CPU. Every machine instruction is preset by the computer, and the portability of the program is poor. Java does not compile for a specific CPU, but compiles programs into "intermediate code" called bytecode, which can be interpreted and executed on any system that provides Java Virtual Machine (JVM).

7.JIT(Just In Time) is used to directly convert bytecode into high-performance local machine code, thus improving the running speed of the program. JIT is a part of Java virtual machine.

Bin folder under 8.8. The SDK installation directory contains compiler javac.exe, interpreter java.exe and other executable files.

9. In order to facilitate the use of Java compilers and interpreters, bin should be included in the path setting. Under the windows operating system, you can right-click my computer and enter the variable name and variable value (path) in the window of Properties → Advanced → Environment Variables, or enter the following command under MS-DOS: path F:\JDK 1.4\bin.

10. Compilation process of Java program: file name. Java(java source program) → javac.exe (bytecode file generated by Java compiler) →Java virtual machine (JIT interprets bytecode file and generates high-performance local machine code) →Java application (executed by Java interpreter java.exe) /Java applet (executed by browser).

11.JSP (Java server pages) is a technical standard for dynamic web pages launched by Sun Company in 1999. JSP is based on Java Servlet, and its technology is similar to ASP (Dynamic Server Page). The programming language of ASP is VBScript. The programming language of JSP is Java. JSP completely overcomes the shortcomings of scripting language-level language execution, can get rid of the constraints of hardware platform and the advantages of running after compilation, and has the characteristics of separating dynamic pages from static pages.

12. Indonesia has an island rich in coffee called Java, and its Chinese name is Java. The developer named this new language Java, which means to serve a cup of hot coffee to the world.

2.Java object-oriented programming

1. class: a collection of objects with the same characteristics and behaviors, which is a template for creating objects.

2. Object: an instance of a class. Each object from the same class has similar but possibly different characteristics.

3. Attribute: data that distinguishes an object and is used to determine its appearance, state and other attributes.

4. Behavior: What the object itself can accomplish. Behaviors can be used to modify the properties of an object, accept information from other objects, and send messages to other objects that perform tasks for them.

5. Inheritance: Let one class inherit all the behaviors and attributes of another class. Classes that inherit from a class are called subclasses, while classes that inherit from them are called superclasses. A class can only have one superclass, but there can be countless subclasses (the only task of subclasses is to point out the differences between them and superclass behaviors and attributes). All classes in java inherit from top-level class objects (Object defines the inheritance behavior of all classes in the Java class library). If the newly defined class is not a subclass of another class, Java will assume that the new class inherits directly from the Object class, and Java only allows but inherits.

6. Method overloading: When creating an object, Java will track every variable defined by this object and every variable defined by every superclass of this object. This object can access all the method names of its classes and superclasses, which are dynamically determined when using methods. When calling a method, the interpreter will first check the class of the object of this method. If not, it will continue to search in the superclass of this class, and so on. When the method defined in the subclass is the same as the method defined in the superclass in terms of method name, return type and parameters, in this case, the interpreter searches upward from the current class to find the nearest target method, ignoring the same upward method (a method with the same name as the method in the superclass can be defined in the subclass, which returns type and parameters to prevent calling the method in the superclass).

7. Interface: A set of methods that allow objects to call methods other than themselves and methods inherited from superclasses. Methods in the interface do not define this behavior, but leave it to the class that implements the interface. Java uses interfaces to solve * * *.

8. Package: Classes and interfaces are contained in packages. The packages of Java packages contain smaller packages that define a specific subset of Java functions. Packages in Java are introduced by "import package name" (such as: import java.awt.color), and the Java.lang (basic language feature) package is loaded by default, so there is no need to introduce data types in III. Java。

1.Java language uses unicode character table, the first 256 characters of unicode character table are ASCII code table, and the climate includes language characters of many countries.

2.Java data type

& lt 1 & gt; Boolean type: Boolean

Boolean variables only allow two values, true and false.

& lt2> integer type:

1/ plastic: int

Int-type variables occupy 4 bytes of memory (byte, a byte is composed of 8 bits, and the bits have two states: 0 and 1), accounting for 32 bits, and the value range is -2 3 1 to 2 3 1 minus 1.

2/ Byte Type: Byte

Byte variables occupy memory 1 byte, accounting for 8 bits, and their values range from -2 to 2 minus 1.

3/ Short shaping: short

Short-type variables occupy 2 bytes of memory, accounting for 16 bits, and their values range from -2 to 15 minus the power of 2 1.

4/ Long Shaping: Long

Long variables occupy 8 bytes of memory, accounting for 64 bits, and the value range is -2 to the 63rd power minus 1.

& lt3> Character Type: Character

Char-type variables occupy 2 bytes of memory, accounting for 16 bits, and the value range is 0-65535.

& lt4> floating-point type

1/ Single precision decimal: floating point number

Floating-point variables occupy 4 bytes of memory, accounting for 32 bits, and their values range from-38th power of 10 to-38th power of 10 and from-38th power of 10 to-38th power of10.

2/ Double Decimal: Double precision

The Double variable occupies 8 bytes of memory, accounting for 64 bits, and its values range from-308th power of 10 to 10 to-308th power of-10.

3. Conversion of basic data types

The order of type precision from "bottom" to "high" is byte→short→int→float→double.

When assigning the value of the variable at the bottom of the level to the variable at the top of the level, the system automatically completes the conversion (for example, float x= 100), but when converting the variable at the top of the level to the variable at the bottom of the level, the forced type conversion operator must be used. The format is: type at the bottom of level (value of type at the top of level)/value of type at the bottom of level (for example: int x).

Step 4 arrange

Array is a compound data type, which consists of the same type of data in order.

& lt 1 & gt; Declare array:

1/ Declare 1 dimensional array: array element type number name []/array element type [] array name (for example: floatboy [], doublegirl [], charcat []).

2/ Declare two-dimensional array: array element type number name [] []/number element type [] [] array name (for example: float a [] [], double b [] [], char [] [] d).

& lt2> create an array.

Declaring an array only gives the array name and element data type and does not allocate memory space.

Allocate memory space: array name = new array element type [array element number] (for example: floatboy []; boy = new float[4]/int size = 4; double number[]=new double[size])

Four. operator

1. addition and subtraction operators:+,-(for example: 2+39,908.98-26), binocular operator.

2. Multiplication and division operators: *,/(for example: 2 * 39,908.36/85), binocular operators.

3. Congruence operator:% (for example, 5%5), binocular operator, with priority of 3.

4. Self-increasing and self-decreasing operators:++,-(e.g. 5++, 1-), monocular operators.

5. relational operators: >,<,>=, & lt=,==,! = (for example:10 >; 5,5 & lt 12, 10 & gt; =5,5 & lt; = 10,4==4,3! =5), binocular operator

6. Logical operator:&; & amp,||,! (For example: (4-3 >; 0)& amp; & amp(8+5 & lt; 8),(4-3 & gt; 0)| |(8+5 & lt; 8),! (4-3 >0)), where & amp & amp||| is a binocular operator! Is a monocular operator

7. Assignment operator: = (for example: int i=5), binocular operator.

8. Bit operator:

& lt 1 & gt; Bitwise and:&;

The bits corresponding to plastic data A and B are 1, so the result is 1, otherwise it is 0, binocular operator.

For example:

A: 00000000000000000000000000000000000000000011

b: 1000000 1 100 10 1 1 1 1 100 1 1 1 1 10 10 1065438

———————————————————

c:0000000000000000000000000000000000 1 1

& lt2> Bitwise or: |

The bits corresponding to plastic data A and B are all 0, so the result is 0, otherwise it is 1, binocular operator.

For example:

A: 00000000000000000000000000000000000000000011

b: 1000000 1 100 10 1 1 1 1 100 1 1 1 1 10 10 1065438

———————————————————

c: 1000000 1 100 10 1 1 1 1 100 1 1 1 1 1 1065438

& lt3> bit by bit: ~

The corresponding bit of plastic data A is 0, then the result is 1, otherwise it is 0, monocular operator.

For example:

Answer:10000001100111100/kloc-0.

———————————————————

c:0 1 1 1 1 10 0 10 10 1000 1000 1 100 0 100 0 10 10 100

& lt4> Bitwise XOR:

If the bits corresponding to plastic data A and B are the same, the result is 0, otherwise it is 1, binocular operator.

For example:

A: 00000000000000000000000000000000000000000011

b: 1000000 1 100 10 1 1 1 1 100 1 1 1 1 10 10 1065438

———————————————————

c: 1000000 1 100 10 1 1 1 1 100 1 1 1 1 1 1065438

9. Examples of operators

Binocular operator has an object on the left and a class on the right. When the object on the left is created by the class on the right, the result of this operator is true, otherwise it is false.

Verb (abbreviation of verb) Java statement

1. Method call statement: a statement that calls an object method.

For example: System.out.println("Hello ")

2. Expression statement: a statement composed of expressions.

Example: 3>2, int i=5

3. Complex sentences: All {} symbols are complex sentences.

For example:

{

z = 23+x;

system . out . println(" Hello ");

}

4. Packing declaration and import declaration: packing and packing introduction declaration.

5. Control statement

& lt 1 & gt; Conditional statement: if-else

Example: if (expression) {Nogan statement; }else{ Nogan statement; }

& lt2> switch statement: switch

Eg:switch (expression) {case: constant value 1: Nogan statement; Break; Case: Constant value 2; Nogan statement; Break; Case: constant value n: Nogan statement; Break; Default: Nogan statement}

6. Loop statement

& lt 1 & gt; Times loop statement: for

Example: for (expression1; Expression 2; Expression 3){ Nogan statement; }

& lt2> conditional loop statement while/do-while

Example: while (expression) {Nogan statement; }/do{ Nogan statement; }while (emoticon);

* The difference between while and do-while loop statements is that while loop statements will not be executed if the conditions are not established, while do-while loop language will be executed once before making a judgment.

& lt3> Use Interrupt in Loop Body and Continue

Break: jump out of the current loop.

Continue: End this cycle.

Static keyword of intransitive verb

1. class variable: the variable modified with the static keyword is a class variable, and the class variables of all objects share a piece of memory, that is, changing the class variable of an object will affect the values of all objects in the class variable, and the class variable can be directly called by the class.

2. Class method: the method decorated with static keyword is a class method. When instantiating a class, the instance method assigns an entry address, and when creating a class, the class method assigns an entry address, so the execution effect of the class method will affect the effect of all objects owned by the class method, and the class method can be directly called by the class.

7. This keyword

The this keyword represents the object that uses this method.

For example:

Level a

int x;

void f(){

this . x = 100;

}

}

In the given example, this uses the f method to represent the current object, and this.x uses the f method to represent the friendly variable x of the current object.

* This is usually used to distinguish between member variables and local variables when their names are the same, that is, add this keyword in front of member variables.

Eight. Access right keyword

The Access right/accessor class itself, class objects and subclasses of class objects.

Private people can access it, but they can't access it.

Protected can access, inaccessible can access.

The public can visit, visit, visit.

Friends can access the same package and can access it.

* The access right of member variables and member methods that have not been modified by private, protected and public keywords is friend, and friend is the default access right.

Nine. Final keyword

1.final class: the final class cannot be inherited (for security reasons, the String class of eg:java is very important for compilers and interpreters and cannot be easily changed, so it is decorated as the final class).

2.final method: The final method cannot be overridden.

3. Final Attribute: The final attribute is a variable.

X. super keywords

1. Call superclass constructor with super keyword.

For example:

Class a extends B{

Public static void main (strinargs []) {

Super ("hellow");

}

}

This example uses a super key to call the super class B constructor of class A..

2. Call hidden members and methods of superclass with super keyword.

For example:

Class a extends B{

Private int x;;

Public void printing () {

x = 100;

system . out . println(" x = "+x ");

}

Public static void main (strinargs []) {

super . x = 150;

super . print();

}

}

In this example, the super keyword is used to call the hidden method print () and the hidden property x of superclass B of class A.

Chapter II Interfaces, Exceptions and Packages

I. Interface

1.interface keyword

The Interface keyword is used to declare an interface. Format: Interface Name.

2. Declarations of constants and methods in the interface (not implemented)

For example:

Interface print table {

final int MAX = 100;

void add();

float sum(float x,float y);

}

3. Implement keywords

A class declares that it uses one or more interfaces by using the implements keyword. Format: class object name implementation interface name 1, interface name 2 ... interface name n

For example:

Import javax.swing. *;

Interface display {

Public void show ();

}

Class test extension JFrame implementation show{

Public static void main (strinargs []) {

Test T = new Test();

t . show();

}

Public void show(){

System.out.println ("I used the interface method");

}

}

Two. deformity

1. exception: some errors that may occur when the program is running.

2. Exception class: An exception class is an exception class, and the subclasses corresponding to the exception class correspond to different exceptions.

3.try-catch keyword: the try-catch keyword is used to handle exceptions. When a possible exception is placed in the try part of the statement, when an exception occurs in the statement in the try part, the try part automatically ends and the corresponding catch part is executed. The try-catch keyword can have a catch structure to handle the corresponding exceptions respectively.

4. User-defined exception class: inherit the exception class, and you can customize the exception.

For example:

Class MyException extended exception {

String message;

MyException(){

Message= "The number is not a positive number";

}

Common string toString(){

Return message;

}

}

Level a

Public void f(int n) throws MyException{

If (n & lt0){

throw(new my exception());

}

}

Public static void main (strinargs []) {

A A = new A();

Try {

a . f(- 1);

}

catch(MyException e){

system . out . println(e . tostring());

}

}

}

& lt 1 & gt; In this example, the MyException class inherits the Exception class, so the MyException class becomes a custom exception class.

& lt2> In the method declaration, the throw keyword is used to declare the Nogan exception to be thrown, and the throw keyword is used to give the specific conditions or operations for generating the exception in the method.

& lt3 & gtfinally keyword is used after catch keyword. Whether the program in the try keyword is abnormal or not, the program in the finally keyword will be executed after the tye and catch keywords are executed.

5. Abnormal class structure

Throwable class has two subclasses: error class and exception class.

The Error class describes the exception that the program does not want to catch in the normal environment. When an exception of the Error class occurs, the program usually stops running.

The Exception class describes the exception that the program should catch.

6. Common exception classes

The package with the class name triggered an exception condition.

& lt 1 & gt; Occurs when an illegal number operation occurs in the ArithmeticException class java.lang (for example, the divisor is 0).

& lt2 & gtarrayindexoutofboundsexception class java.lang accesses an array with an illegal index value (for example, the index is either negative or larger or smaller than the size of the array).

& lt3 & gtArrayStoreException class java.lang saved the wrong type object in the object array.

& lt4> When the ClassCastException class java.lang converts an object into its non-instance subclass,

& lt5 & gtClassNotFoundException class java.lang cannot find its corresponding class file when calling the class.

& lt6 & gtEmptyStackException class java.lang retrieves items from an empty Stack (raised by methods in the stack class).

& lt7> when a file object is accessed by the FileNotFoundException class java.io, the file object does not exist.

& lt8> when the IllegalArgumentException class java.lang passes an illegal parameter to a method,

& lt9 & gtInterruptedException class java.lang A dormant thread or a suspended thread may be interrupted before the end of the hibernation time or before calling the resume () method (the dormant thread or suspended thread should be prepared for this exception).

& lt 10 > When passing invalid parameters to a method,

& lt 1 1 & gt; IOException class java.io has an error signal when reading and writing files (methods using streams often encounter exceptions).

& lt12 > the MalformedURLException class when the URL provided by java.net is unsatisfactory (this exception needs to be handled when creating URL).

<13 > when the java.lang String of numberformatexception class is converted into a number, the string can't actually represent a number (for example, strings = "1000 CA", and not all the values in the string object s of string class are numeric strings).

& lt 14 & gt; The stringindexoutofboundsexception class java.lang indexes outside the string boundary.

& lt 15 > when the variable does not allocate memory space, the NullPointerException class java.lang will be accessed.

(for example: buttonb [] = newbutton (); for(int I = 0; I<2; i++){add。 (b[I]); }, in this example, although an object array B of the Button class is created, it is not initialized, so an exception of the NullPointerException class will be generated when accessing the object number B.