Beijing Rong Yi Tong Information Technology Co., Ltd. Java Pen test

Source: Internet
Author: User
Tags new set

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

Related Article

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.