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

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

Linda Hamilton
Linda HamiltonOriginal
2024-11-08 07:41:02886browse

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

For example:

sysout expands to:

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

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);

Log4J 2

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

Log4J

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

JUL

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

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!

Statement:
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