// Forcodes.java (c) 2004 Kari Laitinen // http://www.naturalprogramming.com // 2004-03-07 File created. // 2004-10-10 Last modification. class Forcodes { public static void main( String[] not_in_use ) { int number_of_codes_on_this_line = 0 ; System.out.print( "\n The visible characters with codes from 20" + "\n to 7F (hexadecimal) are the following:\n\n "); for ( int numerical_code = 0x20 ; numerical_code < 0x80 ; numerical_code ++ ) { char character_to_print = (char) numerical_code ; System.out.print( character_to_print + " " ) ; System.out.printf( "%x ", numerical_code ) ; number_of_codes_on_this_line ++ ; if ( number_of_codes_on_this_line == 8 ) { System.out.print( "\n " ) ; number_of_codes_on_this_line = 0 ; } } } } /*** Multiline comment: Another possibility to convert an int value to a hexadecimal string would be to write: String numerical_code_as_hexadecimal_string = Integer.toHexString( numerical_code ) ; *****/