How do I get the length of an array in 1.java?
If it is an array, it is: array. length property;
If it is a string, it is: string. Length () method;
If it is a collection, it is: collection. Size () method
What
is the difference between 2.int and integer?
Such as:
int num = integer.valueof ("12");
int num2 = Integer.parseint ("12");
ValueOf and Parsexx through the wrapper of the basic data type to convert the string to XX
Generics require classes.
1.int Initial value is 0//integer initial value is null
2.int is the basic type,integer is the wrapper class for int: For data type conversion
Integer i =1;int II = 1, the two will be equal, because the integer will be automatically unboxing to int, and then to compare
If two are new, they will not be equal.
3.string and StringBuffer differences:
Simply put, there is a relationship between a variable and a constant.
The contents of the StringBuffer object can be modified; the Stringbuffer:stringbuffer class belongs to an auxiliary class that can pre-allocate a memory block of a specified length to create a string buffer. This uses the Append method of the StringBuffer class to append the word transmitting string using the + operator to add characters to an already existing string that is much more efficient.
Once a String object is created, it cannot be modified, and the re-assignment is actually two objects. So can be used to share,
The function of this method is to append the content to the end of the current StringBuffer object, similar to a string connection. After the method is called, the contents of the StringBuffer object also change, for example:
StringBuffer sb = new StringBuffer ("abc");
Sb.append (TRUE);
http://blog.csdn.net/lclai/article/details/6141548
When 4.try has a return, will the finally be executed?
Finally, the occurrence of an exception will be performed.
If you close the file stream, the socket stream, and so on, finally will be executed before the return.
5.3>>2 =0
Replace with 2, take counter plus 1
6.16 binary swap 10 binary:
16 of the one-time party +16 of the two-party +16 of the three-time square
10 binary swap 16 binary:
Divide by 16 to take the remainder
Quotient divided by 16 to take remainder
Upside down.
7. There is a 5L spoon, a 6L spoon, to make a 3L
a:5l
b:6l
(1) 5L full, inverted to 6L, at this time B has 5L water (empty 1L).
(2) 5L reload, and then pour to 6L, at this time can only pour 1L, at this time a is left with 4L water.
(3) Pour out the water in B and pour the 4L in a into B, where B has 4L water (empty 2L) and a is empty.
(4) Fill a full, pour to B, can only pour into the 2l,a and left 3L.
The implementation class of MAP is HashMap
8. what is the difference between ArrayList and linklist?
ArrayList is used as an array to hold the object, in such a way that the object is placed in a continuous position, inserting the delete trouble
Linklist store objects in separate spaces, and each space also holds the next linked index to find trouble, starting with the first index to find
9. Package Inheritance polymorphism?
Packaging:
The integration of some functional packaging, hiding the internal implementation mechanism, you can change the internal structure of the class without affecting the use of the
It also protects the data and exposes only its access methods to the outside world.
Benefits: Specific implementation changes without adjusting user-level code
Inherited:
The son inherits his father's character.
Benefit: The ability to reuse code, inheriting he is creating new classes with existing classes, the newly created classes already contain non-private members and methods, and new properties and methods can also be added.
If a parent class does not have a constructor by default, the subclass will default to super to display the constructor that invokes the parent class when inheriting.
Polymorphic:
Divided into rewrite/reload
Rewrite: Subclass to rewrite methods of parent class
Overloading: A method in a class to represent a variety of his forms.
benefit: only when the program runs the calling method to determine the specific class, you can modify the code to change the program without modifying the source program.
VI. Print Stars
Print pyramids and 99 multiplication tables
int size = 5; for (int i = 0; i < size; i++) { for (int x = 1; <= size-i; x + +) { Sys Tem.out.print (""); } for (int j = 1; J <= I*2+1; j + +) { System.out.print ("*"); } System.out.println (); }
int size = 5;
for (int i = 0; i < size; i++) {
for (int x = 1; <= size-i; x + +) {
System.out.print ("");
}
for (int j = 1; J <= I*2+1; j + +) {
System.out.print ("*");
}
System.out.println ();
}
Interview:
1.SSH of understanding, introducing SSH
Life cycle of 2.Servlet
Loaded--instantiation--service--Destroy
Load: loading is typically done when the Tomcat container is run, when the Servlet class is loaded into Tomcat, or when the client requests it.
instantiation : Reading configuration information, reading initialization parameters, and so on, which are basically performed only once throughout the life cycle. The init () method has already provided the default implementation in the accumulation Genericservlet, and it is not necessary to define it if no special processing is required, otherwise it should be overridden.
The service is typically when a container receives a client request, the Servlet engine creates a ServletRequest request object and a Servletresponse response object. The two objects are then passed as arguments to the service method of the corresponding Servlet object. (This method is a key implementation of the method, the ServletRequest object can obtain information about the request from the client, such as request parameters, etc., Servletresponse object can allow the servlet to establish a response header and status code, and can write the response content returned to the client.) As a point of note, the service method can be omitted when there is a doget () or Dopost () method in the servlet, and the default is to call both methods)
Destruction: destruction is typically a servlet's uninstallation is defined and implemented by the container itself, and the Destroy () method needs to be called before uninstalling the servlet to let the servlet free up the system resources it consumes. While the Java Virtual Machine provides a mechanism for automatic garbage collection, some resources are not processed by the mechanism or deferred for a long time, such as closing files, releasing database connections, and so on. Normally tomcat is off, the servlet will be destroyed, and if you want to destroy it beforehand, you can write a listener
Method of 3.servlet
http://blog.csdn.net/besttaling/article/details/4734030
4.doget and Dopost method difference?
1. The file size is different
Doget method: Data submitted by get is limited in size, usually around 1024 bytes.
Dopoat method: Post mode does not have the data size limit, theoretically transmits how much data can be.
2. The method of transmitting value is different
Doget method: URL with key value to pass value after URL
Dopost Method: Form Submission method
If you do not specify the method property, the property is "get" by default.
Dopost processing the value that the form brings over
(3) Doget () method
The Doget () method is called when a client issues an HTTP GET request through an HTML form or requests a URL directly. The parameters associated with the GET request are added to the URL and sent with the request. The Doget () method should be used when the server-side data is not modified .
(4) DoPost () method
The DoPost () method is called when a client issues an HTTP POST request through an HTML form. The parameters associated with the POST request are sent from the browser to the server as a separate HTTP request. You should use the Dopost () method when you need to modify the server-side data .
5. When are the four major scopes used? (Scopes are the scope of information sharing)
PageContext: Minimum, valid in the current page (JSP), jumping to another page is invalid.
Request: Valid within one request
Session: Browser process, as long as the current page is not closed, is valid, the default 30min
Application: The server, as long as the server does not restart, or is forced to clear, the data is valid
Xiamen Central Control