Java related article index (__java)

Source: Internet
Author: User
Environment Deployment

Eclipse has a rather unfriendly place after the enhanced auto complement is the automatic completion of variable names, we habitually will be skipped by the space, but with its own definition of variable names, but in the enhanced automatic completion, by the function of the space is not skipped but selected , then how to do it.
The search was largely done by modifying the Eclipse source code:
< >eclipse enhanced automatic completion, cancel "=" Equals and space automatic input
Associating eclipse source code, installing Eclipse SDK plugin Basics

1.java jar Command package All files in a folder

Example 1: Archive Two class files into an archive file named Classes.jar:
Jar CVF Classes.jar Foo.class bar.class
Example 2: using an existing manifest (manifest) file ' Mymanifest ' will foo/the directory of all
Files are archived to an archive file called ' Classes.jar ':
Jar CVFM Classes.jar mymanifest-c foo/.

2.eclipse how to add a try catch to a code snippet quickly

Select to add a try ... Catch code snippet, then click the right mouse button, select the sourround with option (replace right-click Shortcut: Alt+shift+z), and if you need to add finally, you can place the cursor in the try line. Then add it through ctrl+1.

3.java string sorted by length size

    public static void Sortstringarray (string[] arrstr) {
        String temp;
        for (int i = 0; i < arrstr.length. i++) {for
            (int j = arrstr.length-1; j > i; j--) {
                if arrstr[i].length () > Arrstr[j].length ()) {
                    temp = arrstr[i];
                    Arrstr[i] = arrstr[j];
                    ARRSTR[J] = temp;}}}
    

4.java to the list to be heavy and keep the original order in the set

1. Go to Heavy
You can take advantage of set collections in Java
2. Keeping order
The Linkedhashset in set is ordered.

5. Why Java methods can not be nested inside the method.

6.Java example-judge two arrays equal

Arrays.equals (Array1,array2)

How to produce a random number in a particular range in 7.JAVA

Value N in Nextint, generating [0,n]

generates a random number between 0-2, including 2

Random rand = new Random ();
int randnum = Rand.nextint (3);

generates a random number between 5-26, including

int randnum = Rand.nextint (22) +5;
IOCommons-io lineiterator Java How to correctly use try Catch finally turn off file Flow Summary use Fileutils simplify your file operations [test]java IO Write file efficiency--comparison of several methods Debug

Infinitesimal and negative infinity of doubled
There may be a stereotype of thinking in the inside, which is sometimes we initialize a value, take Java, an integral type wants to initialize to the smallest integer, then Integer.min_value, if you want to initialize a minimum double type. Double.min_value. Yes, it does, but not as you wish, the Min_value of a Double in Java is a presence greater than 0, where the double.negative_infinity is needed, not the Double.min_value

Regular expression $ error, occurrence invalid escape sequence (valid ones are \b \ \ \ n \f \ r \ \ \)

In Java, the backslash itself has an escape effect, to represent the \in a regular expression, you must use \ escape

On the difference between get and post in http

Java implementation of inverted index

In the implementation of their own time, made a number of minor changes, mainly statistical frequency of the use of hashmap--nums processing logic:
Nums.put (String, Nums.getordefault (string, 0) + 1);

attached Python3 version of the implementation code

Import Collections
map,nums= {},collections.defaultdict (int)

def createindex (FilePath): With
    open ( FilePath as reader: For line in
        Reader:
            sarray=line.strip (' \ n '). Split (') for
            s in sarray:
                list = []
  if s not in map:
                    list.append (filePath)
                    map[s]=list
                Else:
                    list = Map[s]
                    if FilePath not in map[ S]:
                        list.append (filePath)
                nums[s]+=1

filepath={each document path} for
I in range (1,4):
    CreateIndex ( Filepath+str (i) + ". txt") for

i in map:
    print (' {key}:{value} '. Format (Key=i,value=map[i])) for J-in
Nums :
    print ("{key}:{value}". Format (Key=j,value=nums[j]))

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.