Apply for Java, did not expect to go after, said is to make Erlang, a new thing, equivalent to the original Java knowledge all abandoned, learn a new set of Dongdong, had to do. No. 50th Bo Xia Road
Specific pen test can refer to: http://blog.csdn.net/fenglibing/article/details/1753536
1. Give array arr[] a sort
Bubble sort
Public int[] Bubblesort (int[] a) {
for (int i=0;i<a.length;i++) {
for (int j=0;j< (a.length-i-1); j + +) {
if (A[j]>a[j+1]) {
int temp = A[j];
A[J] = a[j+1];
A[J+1] = temp;
}
}
}
return A;
}
2. The following code
public static void Main (string[] args) {
Sorttest test = new Sorttest ();
String str = "1234";
Test.changstr (str);
System.out.println (str);
}
public void Changstr (String str) {
str = "Change str";
}
Run Result:1234
3. Recursive implementation of factorial
public static void Main (string[] args) {
System.out.println (Sorttest.fn (4));
}
public static int fn (int n) {
if (n<1) {
return-1;
}
if (n==1) {
return 1;
}
Return N*fn (n-1);
}
4. Traverse directory and files under folder
public static void Main (string[] args) {
Test test = new test ();
Test.showalldirfile (New File ("F:\\info"));
}
public void Showalldirfile (file file) {
if (File.isdirectory ()) {
System.out.println ("directory:" + File.getabsolutepath ());
file[] files = file.listfiles ();
for (File f:files) {
This.showalldirfile (f);
}
}else{
SYSTEM.OUT.PRINTLN ("FileName:" + file.getabsolutepath ());
}
}
5. The SessionID inside the URL
The HttpServletResponse interface provides encodeurl (String URL) to implement URL address rewriting. For example:
<a href= "<%= response.encodeurl(" Index.jsp?c=1&wd=java ")%>" >Homepage</a>
This method automatically determines whether the client supports cookies. If the client supports cookies, the URL is exported intact. If the client does not support cookies, the ID of the user session is rewritten into the URL. The rewritten output might be like this:
Http://localhost:8080/xxx/index.jsp;jsessionid=091A82E070579D3FA881FE901E532422?c=1&wd=Java
Where Jsessionid followed is the value of Session.getid (), so that the session can be used.
Reference article: http://blog.csdn.net/linbooooo1987/article/details/12843823