Question:

How can you convert int to float in java in the middle of your program?

by Guest59388  |  earlier

0 LIKES UnLike

How can you convert int to float in java in the middle of your program?

 Tags:

   Report

2 ANSWERS


  1. You "typecast" it.

    int i;

    float p;

    i=99;

    p=(float)i;


  2. int i = 100;

    float f = i;

    System.out.println(f);

    System.out.println( (float) i );

    Output:

    100.0

    100.0

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions