Very nice Eclipse tips

xiaoxiao2021-03-06  52

When we travers a List, we will write:

// queries is a list instance That Contains

// a List of string Objects

Iterator it = queries.iterator (); while (it.hasnext ()) {string query = (String) it.next ();

}

In Eclipse, you can get the above things simple: After entering while, press CTRL SPACE, you should see a pop-up list (as shown below):

Choose "While - Iterate With Iterator", Eclipse will automatically generate the remaining code (as shown below):

This is still not finished, have you seen those blue small boxes? You can switch these small boxes one by one by tab. The currently selected box is "iter", our item is named "IT" instead of "iTer", so we directly enter "IT" to replace the automatically generated "iTer", you will find all "iTer" classes The box has become "IT" (as shown below):

Press the Tab key to jump to the "Type" box, change it to "string". Press the Tab button to jump to the "Element" box and change it to "query". To jump out of the box, just press ESC. This is made by eclipse to help you generate the code as the first time:

// queries is a list instance That Contains

// a List of string Objects

Iterator it = queries.iterator (); while (it.hasnext ()) {string query = (String) it.next ();

}

The same thing can be done in the for cycle (as shown below):

Select "for - Iterage over Collection".

Smart is that Eclipse knows that we have declared a list object called "queries", so it automatically adds Queries to for-loop. You should know how to do it.

Try then Switch, IF these things have similar patys. You have nothing to press Ctrl Space (forced activation code auxiliary function), there will be unexpectedly discovered. After the Method parentheses, press Ctrl Shift Space to call out the Method parameter prompt, press Ctrl Space to call different versions of the overloaded Method.

If you are too lazy to use the mouse to press that "maximize button", you will press Ctrl M directly, then press CTRL M to restore, boring?

Sometimes I want to eat and regret, press CTRL Z backwards, but this is slow. Eclipse is an excellent CVS side, but not every project has CVS. How to "look back in history this time? In fact, Eclipse has brought a local historical record, which records the most recent code change. As shown below, select the file you want to fall back, click "Restore from local history".

A "Restore Local History" dialog is popped, you should know how to do it. If you have time, you can take a look at the "Compare With> local history", which shows the comparison of the current file and history.

The Eclipse user who does not use the Debug view is equal to being violent. Here I teach you a trick, the average person is not using. If your program has an exception of Null Pointer, you don't know where it is wrong. What should I do? Switch to the debug view, look at BreakPoints in the upper right corner: Press that exclamation button (Add Java Exception Breakpoint), pop up A dialog (as shown below). Enter nullpointerexception inside, then press OK, which adds a breakpoint that captures NullPointRexception in your file. Whenever the NullPointRexception occurs, Eclipse will suspend commissioning and point out which line throws this NullPointerexception exception.

Nothing, just.

转载请注明原文地址:https://www.9cbs.com/read-116389.html

New Post(0)