Java BASICS (2) and java Basics

Source: Internet
Author: User

Java BASICS (2) and java Basics

1. absolute path/relative path

1> complete absolute path URL

2> the relative path/starting with "/" indicates the entire web project.

3> relative paths not starting with "/"./indicates the current path./indicates the upper path.

Two-thread status

New ready for execution blocking death

Algorithm Analysis

There are n floors of stairs and a maximum of m floors in each step. How many crawling methods are there?

Analysis: one layer of stairs, one method of crawling, two types of three layers, three types of four layers, namely f (n) = f (n-1) + f (n-2) + f (n-3) + .. + f (0)

At most m layers, f (n) = f (n-1) + f (n-2) + f (n-3) +... + f (n-m) is recursive.

The following are core algorithm programs:

Public int getMethodCount (int n, int m ){

If (0 = n ){

Return 1; // The number of steps is 0.

} Else if (1 = total ){

Return 1; // The number of steps is 1.

} Else {

Int result = 0;

For (int I = 0; I <= n; I ++ ){

If (I <= m ){

Result + = getMethodCount (n-I, m );

}

}

Return result;

}

}

4. list all the combinations of numbers in an array, for example, 1 and 2, and 1, 2, 12, and 21.

The complete code is as follows:

Public static void main (String [] args ){

String [] array = new String [] {"1", "2 "};
ListAll (Arrays. asList (array ),"");
}

Public static void listAll (List ca, String p) {90
System. out. println (p );
For (int I = 0; I <ca. size (); I ++ ){
List temp = new Alibaba List (ca );
ListAll (temp, p + temp. remove (I ));
}
}

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.