如何在Java中连接字符串?

时间:2015-10-29 14:43:34

标签: java

<nav id="razonAseg"> <br> <img src="images/2.jpg" alt="Asegurado" width="315" height="628" class="smooth" id="Asegurado" border="0" onclick="getValue('1')"/> <img src="images/1.jpg" alt="Agente" width="315" height="628" class="smooth" id="Agente" border="0" onclick="getValue('2')"/> <img src="images/3.jpg" alt="Contratista" width="315" height="628" class="smooth" id="Contratista" border="0" onclick="getValue('3')"/> <img src="images/4.jpg" alt="Visitante" width="315" height="628" class="smooth" id="Visitante" border="0" onclick="getValue('4')"/> </nav> <div id="content"></div> 将根据循环重复。如何将结果保存为新字符串。例如,如果工作&#34;你好&#34;重复了两次,我现在如何制作&#34; hellohello&#34;作为一个全新的字符串。

function getValue(aval) {
    if (aval == 1) {
        filename = "InsuredReason.html";
    }
    if (aval == 2) {
        filename  = "AgentInfo.html";
    }
    if (aval == 3) {
        filename  = "ContratistaInfo.html";
    }
    if (aval == 4) {
        filename  = "VisitorInfo.html";
    }
    $.ajax({
        url: 'Services.aspx/'+filename,
        type: "GET",
        success: function (data) {
            //alert(data);
            $('#content').html(data);//where data is content of html file
        },
        error: function (er) {
            //alert(er.d);
        }
   });

}

2 个答案:

答案 0 :(得分:1)

只需使用

strKeyword + = strKeyword;

由于java 6经过优化,不需要使用stringbuilder

答案 1 :(得分:1)

string newWord="";
for (int l=0; l<newKeywordLength; l++){           
         newWord+=strKeyword;
}
System.out.print(newWord);
相关问题