title: how to rotate integer for a given number in java?
body: <p>How can I "rotate" numbers, without using array or String?</p>
  
  <p>I have a working code, but it needs further optimizationn.</p>
  
  <p>An example: Given the input number <code>12345</code> with a rotation length of <code>2</code>, the expected output would be <code>34512</code>.</p>
  
  <p>My current code:</p>
  
  <pre><code>int a=12345;
  int n=2;
  int count=0;
  int tmp=1,t1=1;
  int k=1;
  int v=a;
  
  for(int i=0;i&lt;=v;i++) {
      count++;
      v/=10;
      tmp*=10;            
  }
  for(int j=0;j&lt;=count-n;j++) {
      t1*=10;
  }
  tmp=tmp*10/t1;
  k=a%t1;
  
  k=k*tmp+(a/t1);
  
  
  System.out.println(k);  
  </code></pre>