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 4618270
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:14:34+00:00 2026-05-22T02:14:34+00:00

Why this works: Object prova = 9.2; System.out.println(prova); Double prova2 = (Double) prova; System.out.println(prova2);

  • 0

Why this works:

 Object prova = 9.2;
 System.out.println(prova);
 Double prova2 = (Double) prova;
 System.out.println(prova2);

And this doesn’t?

Object prova = 9.2;
System.out.println(prova);
Float prova2 = (Float) prova;
System.out.println(prova2);

I lost 1 hour in my java android application cause of this thing so i had to cast it in a double and than the double in a float or i had an exception

  • 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-05-22T02:14:35+00:00Added an answer on May 22, 2026 at 2:14 am

    Because you are relying on autoboxing when you wrote

    Object prova = 9.2;
    

    If you want it to be a Float, try

    Object prova = 9.2f;
    

    Remember that java.lang.Float and java.lang.Double are sibling types; the common type is java.lang.Number

    If you want to express a Number in whatever format, use the APIs, for example Number.floatValue()

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

Sidebar

Related Questions

This works just fine: protected void txtTest_Load(object sender, EventArgs e) { if (sender is
Can anyone explain why this works: Object ready_lock = new Object(); Object thread_lock =
The Object.keys() method works fine for me with code like this: var foo =
This works fine: var expectedType = typeof(string); object value = ...; if (value.GetType().IsAssignableFrom(expectedType)) {
Normally all this works great for Serializing my object into an Xml string and
How to make this works? : private string KeyChar = ; public void SetMyKey(object
I populate a listview from a JSON object. This works fine setListAdapter(new ArrayAdapter<String>(this, R.layout.list_items,
I use regsvr32 MyCOM.dll to register my com object for my application. This works
This works: Object[] array = new Object[3]; array[0] = ddd; array[1] = new Integer(12);
This works now for those new to this question: class ensureparams(object): Used as a

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.