java - can i use an if statement to append to a string? -


right have following code, , i'm trying code append string instead of system.out.println. know worded oddly, not sure how put it.

char[] c = inputstring.tochararray();      for(char ch : c)       {          if(ch <=88 && ch>=65 || ch<=120 && ch>=97)           system.out.print(character.valueof((char) (ch+2)));           else             if (ch =< 1)                 system.out.print(character.valueof((char) (ch-24)));             else                  if (ch == 2)                     system.out.print(character.valueof((char) (ch-24)));                 else             system.out.print(ch); 

all need defining string next c[] arrayand add characters operator += , @ end have complete string of want,

char[] c = inputstring.tochararray(); string str = ""; for(char ch : c)  {      if(ch <=88 && ch>=65 || ch<=120 && ch>=97) {         str += character.valueof((char) (ch+2));      } else{         if (ch =< 1){             str += character.valueof((char) (ch-24));         }else {             if (ch == 2){                 str += character.valueof((char) (ch-24));             }else{                 str += ch;             }         }      } }  // str result want can operation on wish 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -