IntegerPrinter.java 692B

123456789101112131415161718192021222324252627282930
  1. public class IntegerPrinter {
  2. public String printIntegerAsBinary(int value){
  3. String bin = Integer.toBinaryString(value);
  4. System.out.println(bin);
  5. return bin;
  6. }
  7. public String printIntegerAsOctal(int value){
  8. String octal = Integer.toOctalString(value);
  9. System.out.println(octal);
  10. return octal;
  11. }
  12. public String printIntegerAsHexadecimal(int value){
  13. String hex = Integer.toHexString(value);
  14. System.out.println(hex);
  15. return hex;
  16. }
  17. // public static void main(String[] args){
  18. //I don't think it makes sense to have a main method here? Commented
  19. //out to be safe.
  20. // }
  21. }