Home > Java > javaTutorial > body text

What Java Code Templates Do You Use in Eclipse That Go Beyond the Basics?

Linda Hamilton
Release: 2024-11-08 07:41:02
Original
891 people have browsed it

What Java Code Templates Do You Use in Eclipse That Go Beyond the Basics?

Useful Java Code Templates in Eclipse

In Eclipse, you can create various Java code templates by:

Window > Preferences > Java > Editor > Templates
Copy after login

For example:

sysout expands to:

System.out.println(${word_selection}${});${cursor}
Copy after login

You can activate this code by typing sysout and then pressing CTRL SPACE.

What useful Java code templates are you currently using?

Please include a name and description of the template and why it’s great.

I'm looking for an original/novel use of the template rather than an existing feature built in.

  • Create Log4J logger
  • Get swt color from display
  • Syncexec - Eclipse Framework
  • Singleton mode/enumeration Singleton Generate
  • Readfile
  • Const
  • Traceout
  • Format String
  • Code Review Comments
  • String Format
  • Try Finally Lock
  • Message format i18n and record
  • Equalsbuilder
  • Hashcodebuilder
  • Spring object injection
  • created FileOutputStream

We received the recommended template:

SLF4J

${:import(org.slf4j.Logger,org.slf4j.LoggerFactory)}
private static final Logger LOG = LoggerFactory.getLogger(${enclosing_type}.class);
Copy after login

Log4J 2

${:import(org.apache.logging.log4j.LogManager,org.apache.logging.log4j.Logger)} 
private static final Logger LOG = LogManager.getLogger(${enclosing_type}.class); 
Copy after login

Log4J

${:import(org.apache.log4j.Logger)}
private static final Logger LOG = Logger.getLogger(${enclosing_type}.class);
Copy after login

JUL

${:import(java.util.logging.Logger)}
private static final Logger LOG = Logger.getLogger(${enclosing_type}.class.getName());
Copy after login

The above is the detailed content of What Java Code Templates Do You Use in Eclipse That Go Beyond the Basics?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template