1, the definition has stringbuffer s1=new StringBuffer (Ten); S1.append ("1234") what are S1.length () and s1.capacity () respectively?
Length () returns the current lengths
When the append string length is less than the initialization length, capacity returns the initialization length, and returns the length of the increment if it is greater than the initialization length.
The default length of Ps:stringbuffer and StringBuilder is 16;arraylist and linkedlist default length is 10.
2.
after executing the following code, the elements in the numberlist are:
list<integer> numberlist =newarraylist<integer> ();Numberlist.add (2);Numberlist.add (4);Numberlist.add (1);Numberlist.add (3);Numberlist.add (5);for (int i =0;i<numberlist.size (); ++i){int v = numberlist.get (i);if (v%2==0){Numberlist.remove (v);}}System.out.println (numberlist);
1.ArrayList After the element is deleted, the remaining elements move forward sequentially, so the subscript keeps changing, and size () decreases;The 2.remove () method calls remove (int index), not remove (Object O), so the element at the index index is deleted3, there are four ways to implement session tracking technology: URL Rewrite, hide form fields, cookies, session.
1). Hide form fields: <input type= "hidden", ideal for session applications that require a large amount of data storage.
2). URL rewrite: The URL can be appended with parameters, and the server's request is sent together, these parameters are name/value pairs.
3). Cookie: A cookie is a small, named data element. The server uses the Set-cookie header to use it as an HTTP
Part of the response is delivered to the client, the client is requested to save the Cookie value, and the subsequent request to the same server uses a
The Cookie header returns it to the server. Compared to other technologies, one of the advantages of cookies is that after the end of a browser session, even
It can still retain its value after the client computer restarts
4). Session: Bind an object to a session using the SetAttribute (String str,object obj) method
New Ket Web Java Brush Question 10.3