Results 1 to 2 of 2
  1. #1
    zeal3 is offline Member
    Join Date
    Oct 2009
    Rep Power

    Default Need help with java wrapper class.

    im having troubles with my project

    1. Prompt for and read in an integer, then print the binary, octal and hexadecimal representations of that integer.

    2. Print the maximum and minimum possible Java integer values. Use the constants in the Integer class that hold these values -- don't type in the numbers themselves. Note that these constants are static (see the description on page 140 and the signature on page 819).

    3. Prompt the user to enter two decimal integers, one per line. Use the next method of the Scanner class to read each of them in. (The next method returns a String so you need to store the values read in String variables, which may seem strange.) Now convert the strings to ints (use the appropriate method of the Integer class to do this), add them together, and print the sum.

    what i have so far and i know this is wrong

    import java.lang.Integer;
    import java.util.Scanner;

    public class integer

    public static void main (String[] args) {

    int binary;
    int octal;
    int hexadecimal;

    final String toBinaryString;

    Integer toBinaryString = new Integer (33);

    System.out.println(toBinaryString(toBinaryString)) ;
    Scanner scan = new Scanner(;


  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    New Zealand
    Rep Power


    There are plenty of things wrong with that code - but the compiler will tell you what they are. If you have any problems understanding compiler messages, ask about them. As it stands you don't really have a question.

    Work one step at a time. Beginning with this:

    1. Prompt for and read in an integer, then print the binary, octal and hexadecimal representations of that integer.
    Get a compilable, working version of this before moving on.

    I notice that you declare three int variables: binary, octal and hexadecimal. This seems to reflect the (very common) misunderstanding that there are different sorts of number. "binary", "octal" and the rest really refer to different sorts of string representations of a number.

    So in attacking this first part of the question you need only one int variable whose value you will get from the user input. The binary, octal and hex things you output will be of type String. (you may or may not find yourself needing variables for them.)

    And a final piece of generic-advice-for-want-of-a-question: use the API docs. Specifically those for the Integer class. There are lots of good things there.

Similar Threads

  1. Custom Class, Wrapper/Subclass?
    By Moncleared in forum Advanced Java
    Replies: 3
    Last Post: 02-10-2009, 12:08 AM
  2. Yet another Wrapper Class confused guy.
    By JAdeline in forum New To Java
    Replies: 2
    Last Post: 08-15-2008, 05:04 AM
  3. Wrapper Class
    By haiforhussain in forum New To Java
    Replies: 6
    Last Post: 06-24-2008, 09:08 AM
  4. problem in wrapper class
    By binoympappachen in forum New To Java
    Replies: 4
    Last Post: 12-13-2007, 01:31 PM
  5. Exception Failed to Generate Wrapper Class on WebLogic
    By christina in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 03:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts