Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create an Eclipse template to println a variable in scope

Tags:

java

eclipse

In programming, I often have situations where I want to print a variable to the console.

int myVar = 23;
System.out.println("myVar" + myVar);

I'd like to automate the task by outsourcing it to an Eclipse template. So far, this is the template I have prepared:

System.out.println((NAME OF VAR IN QUOTES?) + ${var});

How would I put the name of var in a String?

like image 908
Michael Avatar asked Jul 18 '26 05:07

Michael


2 Answers

You are very close. It's just easy as that:

System.out.println("${var} " + ${var}); // quote creates the difference
like image 76
Simon Martinelli Avatar answered Jul 20 '26 19:07

Simon Martinelli


I use:

System.out.println("${var}:\t" + ${var});
like image 33
ifly6 Avatar answered Jul 20 '26 17:07

ifly6