title: Is there any way to sort the digits of an Integer without any ARRAY in JAVA?
body: <p>I am trying to sort the digits of an Integer in descending order in JAVA but I am not allowed to use any array.</p>
  
  <p>This was given to me as an assignment in class and below is a code that I tried but failed.</p>
  
  <pre><code>import java.util.Scanner;
  class descend
  {
      public static void main(String args[])
      {
          int a=0,loc=0,parse=0,temp=0,big=0;
          Scanner scan = new Scanner(System.in);
          System.out.print("Enter a number");
          a=scan.nextInt();
          String s=Integer.toString(a);
          int l=s.length();
          for(int i=0;i&lt;l;i++)
          {
              big=(int)(s.charAt(i));
              loc=i;
              for(int j=i+1;j&lt;l;j++)
              {
                  parse=(int)(s.charAt(j));
                  if(parse&gt;big)
                  {
                      big = parse;
                      loc=j;
                  }
              }
              temp=parse;
              s.charAt(i)=s.charAt(loc);
              s.charAt(loc)=temp
          }
          System.out.print(s);
      }
  }
  </code></pre>
  
  <p>Here I get a syntax error at <code>s.charAt(i)=s.charAt(loc);</code> and <code>s.charAt(loc)=temp;</code> that a variable is required but a value is given.</p>
  
  <p>Please help me out with this and I shall always be grateful to you.</p>