Java Learning Note 1

Source: Internet
Author: User

The actual order of initialization:

1) Before anything else happens, the storage space allocated to the object is initialized to the binary 0.

2) Call the base class constructor as described earlier, at which point the overridden method is called (to be called before the export class constructor is called)

3) invokes the initialization method of the member in the order in which it is declared. 4) Call the body of the constructor that exports the class.

There is a guideline when writing a constructor: "Use the simplest possible method to get the object into a normal state, and avoid invoking other methods if you can." In the constructor.

The only method that is safe to use is the final method in the base class (also applicable to private methods). ---> These methods cannot be overwritten, so

There will be no problem.

One common guideline is: "To express the difference between behaviors with inheritance and to use fields to represent changes in state." ”

The difference between Collection and collections.  Collections is a Java.util class that contains a variety of static methods related to collection operations. Collection is an interface under Java.util, which is the parent interface of various collection structures.

The Set does not have a get () method, it needs to traverse with Iterator (), there is no order Iterator Iterate=set.iterator () in//set,//set set=new HashSet ();

Polymorphic:

One: Static polymorphism----function overloading of three kinds of cases;

Two: Dynamic polymorphism, parent class reference to sub-class object; function parameter passing;

? To pass parameters: ①,?param1=value1&param2=value&, ..... ②,request.getparameter ("param1");

e.g. <a href= "p1.jsp?param=<%=n%>" ><%=n%></a>//n is a variable or <a href= "p1.jsp?param=" +N+ "> <%=N%></a>

Built-in objects:

1,out, automatically instantiate when the page is loaded into the server;

2,request, gets the parameters of the client, stream; GetParameter (String);  Obtaining communication information, such as Getrequesturi (), etc.; is also one of the four areas;

3,response, responsible for managing HTTP links, Response.sendredirect ("string")//url, to the target page the value within the request is lost,

or <jsp:forward page= ""/>

ServletContext Application=this.getservletcontext ();

RequestDispatcher rd=application.getrequestdispatcher ("path");

Rd.forward (request,response);//url unchanged, the value within the request is not lost

The difference is the reservation of the request parameter; Forward is the server internal jump, if you want to jump to the server outside the URL, to use the Redirect method;

Add a Cookie object (saved on the client), Addcookie (New Cookie ("username", "Yookoo")); Read cookie,cookie[] cookies=request.getcookies ();

4,session, sharing variable content between multiple pages (server side)

5,application, which is used by multiple users to share some global information longer than the session, disappears after the server is switched off.

6,pagecontext access to the namespace;

About attributes within a tag:

Name is obtained from elsewhere, the ID is own;

Java Learning Note 1

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.