Using setText function - mixing text and variables

andyw27
andyw27 used Ask the Experts™
on
I'm using the setText function.

What the synatx for mixing variables and text ?

Is it something to what used in c printf("Variable1 is %d", variable1);

Many thanks.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
JLabel myLabel = new JLabel("Test");
myLabel.setText("Var1 value: " + myVar1.toString() + ", Var2 value: " +  myVar2.toString());

Author

Commented:

I'ved tried the above code but get:

int cannot be dereferenced error ?

Any idea's?
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

Author

Commented:

Its okay I fixed it now, it did'nt need the toString method.

Commented:
in java you dont need to string convertion to write int variables to screen.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial