Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Netbeans

You're reading from  Mastering Netbeans

Product type Book
Published in Aug 2015
Publisher
ISBN-13 9781785282645
Pages 348 pages
Edition 1st Edition
Languages
Toc

Table of Contents (17) Chapters close

Mastering NetBeans
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Getting Started with NetBeans 2. Editing Files and Projects 3. The NetBeans Developer's Life Cycle 4. Managing Services 5. Database Persistence 6. Desktop Development 7. Creating the Business Layer 8. Creating the Web Tier 9. Creating and Consuming Web Services 10. Extending NetBeans Index

Code templates and code snippets


In the previous section, we saw how to create and customize templates for different file types. This can be very useful when creating new files.

NetBeans takes automatic code creation even further, however, with the ability to define both code templates and code snippets. Code templates allow a short piece of code to be entered within the main source code editor that is expanded into a larger template upon pressing the Tab key.

Inserting code using code templates

First, let's take a look at code templates. NetBeans provides over 100 code templates for the Java language and many more for JavaScript, HTML, and others. Some of the more common code templates are shown in the following table:

Code template

Description

pf

Expands to public final

do

Expands into a do … while loop

fori

Expands to a for loop

log

Expands to a Logger class to output a log entry

serr

Expands to System.err.println("");

sout

Expands to System.out.println("");

...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}