Luís Tavares Luís Tavares - 1 year ago 124
Java Question

Inserting a variable inside a String

This is probabily a pretty simple issue but since I'm working with 1.3 IDE I can't use the most common method to do this.

String at_cmd_response = atc.send("AT+CMGS=\"+35111111111\"\r");

I need to introduce a string called number which holds a number like "35191xxxxxxx" in at_cmd_response. To do so, I've seen the String.format method but I can't use it due to my IDE.
Is there another way to do this?


Answer Source

Simple String concatenation (+) will work:

String at_cmd_response = atc.send("AT+CMGS=\""+number+"\"\r");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download