@@ -0,0 +1,906 @@
+// Use ShowBits as a local class.%0Aclass LocalClassDemo %7B%0A  public static void main(String args%5B%5D) %7B%0A    %0A    // An inner class version of ShowBits.%0A    class ShowBits %7B%0A      int numbits;%0A      %0A      ShowBits(int n) %7B%0A        numbits = n;%0A      %7D%0A      %0A      void show(long val) %7B%0A        long mask = 1;%0A        %0A        // left-shift a 1 into the proper position%0A        mask %3C%3C= numbits-1;%0A        %0A        int spacer =0;%0A        for(; mask != 0; mask %3E%3E%3E= 1) %7B%0A          if((val & mask) != 0) System.out.print(%221%22);%0A          else System.out.print(%220%22);%0A          spacer++;%0A          if((spacer %25 8) == 0) %7B%0A            System.out.print(%22 %22);%0A            spacer = 0;%0A          %7D%0A        %7D%0A        System.out.println();%0A      %7D%0A    %7D%0A    %0A    for(byte b = 0; b %3C 10; b++) %7B%0A      ShowBits byteval = new ShowBits(8);%0A      %0A      System.out.print(b + %22 in binary: %22);%0A      byteval.show(b);%0A    %7D%0A  %7D%0A%7D%0A

Use ShowBits as a local class