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

  • Home
  • SEARCH
  • 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 8206013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:30:14+00:00 2026-06-07T08:30:14+00:00

So, In Java, you know how you can declare integers like this: int hex

  • 0

So, In Java, you know how you can declare integers like this:

int hex = 0x00ff00;

I thought that you should be able to reverse that process. I have this code:

Integer.valueOf(primary.getFullHex());

where primary is an object of a custom Color class. It’s constructor takes an Integer for opacity (0-99) and a hex String (e.g. 00ff00).

This is the getFullHex method:

public String getFullHex() {
    return ("0x" + hex);
}

When I call this method it gives my this NumberFormatException:

java.lang.NumberFormatException: For input string: "0xff0000"

I can’t understand what’s going on. Can someone please explain?

  • 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-07T08:30:16+00:00Added an answer on June 7, 2026 at 8:30 am

    Will this help?

    Integer.parseInt("00ff00", 16)
    

    16 means that you should interpret the string as 16-based (hexadecimal). By using 2 you can parse binary number, 8 stands for octal. 10 is default and parses decimal numbers.

    In your case Integer.parseInt(primary.getFullHex(), 16) won’t work due to 0x prefix prepended by getFullHex() – get rid of and you’ll be fine.

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

Sidebar

Related Questions

OK - I know I can run my java process like this : java
(Yes I know I can call Java code from Scala; but that is pointless;
like in java I have: Class.getSuperClass().getDeclaredFields() how I can know and set private field
OK - I know that Java generics can be a minefield for the unwary,
We know that we can use a concept Java Package, but I just wanted
So I know that you can add an object in java to something through
I mean, if I declare any access modifier in Java, that modifier can be
I am reading a book about Java and it says that you can declare
I thought that i have some good understanding of Java generics. This code DOES
I know I can find out if a variable is null in Java using

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.