Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9237521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:33:12+00:00 2026-06-18T07:33:12+00:00

I have a couple of question related to these wrapper classes’ methods. Firstly, why

  • 0

I have a couple of question related to these wrapper classes’ methods.

Firstly, why does the method Long (or Integer) take a String as a parameter in the valueOf method? and instead it takes a numeric primitive in the toString method? (see the below examples)

Secondly, why does the second line of code listed below not work (by taking a String as first argument) whereas the first line works fine (by taking a long(or int) as first argument).

Both methods should return the value, respectively in String and in Long type, of the value stated in the first argument converted in the radix specified in the second argument (in this case 8).

String s = Long.toString(80,8)// takes a numeric primitive and it works fine.

Long l = Long.valueOf("80",8)// takes a string as first argument it does not compile,
                              //(as it was because in radix 8 cannot "read" the number 8
                              // and therefore it prompts an NumberFormatException.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T07:33:13+00:00Added an answer on June 18, 2026 at 7:33 am

    Given it doesn’t make sense to have multiple methods which do the same thing, it is logical and not at all surprising that different methods do different things with different arguments.

    Firstly, why does the method Long (or Integer) take a String as a parameter in the valueOf method?

    So it can parse the String and give you a Long or Integer as the docuemntation states.

    and instead it takes a numeric primitive in the toString method?

    valueOf turns a String into an object and toString takes a value and turns it into a String. Given these do almost the opposite things you would expect them to be the other way around.

    Secondly, why does the first line of code listed below not work (by taking a String as first argument) whereas the second line works fine (by taking a long(or int) as first argument).

    80 is a valid decimal which can be turned into an octal number. 80 is not a valid octal (or binary) so you cannot parse it as an octal.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Firstly, I have found a couple of related questions on the issue with links
I have a couple of questions related to TFS and source control: 1) I
I have seen a couple of question regarding creating datasets in DbUnit here on
Have been working on this question for a couple hours and have come close
I have looked a bit into cryptography and related matters during the last couple
Well i guess i ll have to make a trilogy related to the question
I have a couple of questions that are somewhat related so I'm posting them
I have 2 tables (there are more but un related to question) optionValue and
I found a couple of questions somewhat related to this: httpclient-request-set-attribute-question commons-httpclient-adding-query-string-parameters-to-get-post-request but I
I have couple questions regarding some C++ rules. Why am I able to call

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.