Changes to string still in effect after loop ends in Java -


so have script:

class input { public static void main (string[] args){     string hexa;     hexa = "68101005200b10034d201a10162014100d17060520100f06200e101306200409020d0d060f0806200a0f201a101613200b1016130f061a4f2075090a1420100f06201802142007020a130d1a200602141a20151020041302040c4f207802140f4815200a156020525359200c061a14200a1420022012160a150620140e020d0d200c061a14110204064d201410200a1520140910160d050f481520090217062015020c060f201a101620151010200d100f0820151020050604131a11152015090a14200e0614140208064f2078060d0d2005100f064d201a1016132014100d16150a100f200a14200f050311030210130a0d10074f";     int pituus;     pituus = hexa.length();     int = 1;     char luku;     char luku2;     int asc;     string pari;     string koodi;     stringbuilder sb2 = new stringbuilder();     stringbuilder sb = new stringbuilder();     stringbuilder ascii = new stringbuilder();     for(int = 0;a <30;a++){     if (a > 0){         hexa = sb.tostring();     }while(i < pituus){     luku = hexa.charat(i);     luku2 = hexa.charat (i-1);     luku++;            if(luku == 'g'){          luku = '0';         luku2++;     }            else if(luku == ':')                luku = 'a';      if (luku2 == '8')         luku2 = '0';  sb2.append(luku2);  sb2.append(luku);  pari = sb2.tostring();  sb2.setlength(0);  asc = integer.parseint(pari,16);  ascii.append((char)asc);  sb.append(luku2);  sb.append(luku);  i+=2;     }     koodi = ascii.tostring();     system.out.printf("all hex pair values increased by: %d\n%s\n======================\n%s\n",a+1,hexa,koodi);     } } } 

edit2: on version hexa right before program steps, while-loop. inside while loop, program uses old value of hexa. why , how "update" while-loop?

i think inner loop never executed.

because pituus 0 , inner loop isn't executed , sb.tostring(); "" , pituus 0 again, because of inner loop never executed.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -