NetBeans Code Templates: to Array

NetBeans has tons of helpful code templates that expand if you type them and press TAB afterwards. You can also create your own templates. But it really pays to learn some of the existing ones. So I’d like to show some of them here. Today it’s “2ar” which converts an ArrayList to an Array. Typing “2ar” after:

        ArrayList<Integer> integers = new ArrayList<Integer>();

…will expand to:

  ArrayList<Integer> integers = new ArrayList<Integer>();
        class[] integers1 = (class[]) integers.toArray(new class[integers.size()]);

… with the “class” being in “edit mode”, so you can immediately start entering “Integer” at the cursor location and and it will change to:

  ArrayList<Integer> integers = new ArrayList<Integer>();
        Integer[] integers1 = (class[]) integers.toArray(new Integer[integers.size()]);

Here’s a little video:

Dieser Eintrag wurde in netbeans geschrieben. Link merken.

Hinterlasse eine Antwort

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *

Du kannst folgende HTML-Tags benutzen: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>