Paste Search Dynamic
Recent pastes
Converter
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Converter
  9. {
  10.        
  11. public static string toBinary(int num)
  12.         {
  13.                 string binary="";
  14.                 while(num > 0) {
  15.                   binary = (num%2)+binary;
  16.                         num /= 2;}
  17.  
  18.         return binary; 
  19.         }
  20. }
  21.  
  22. class Ideone
  23. {
  24.         public static void main (string[] args) throws java.lang.exception
  25.         {
  26.  int x = 42;
  27.         system.out.print(Converter.toBinary(x));
  28.         }
  29. }
Parsed in 0.009 seconds