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

php - mysql multiple keyword search in any order -

unity3d - Problems porting a GLSL shadertoy shader to unity -

ios - Summing the heights of the views inside my stackview -