How to set value to Float object in Java

4 Answers

0 votes
package javaapplication1;

public class JavaApplication1 {

    public static void main(String[] args) {

        float f = 3.14f;
        
        Float fObj = f;
        System.out.println(fObj);
    }
}
   
/*
      
run:
      
3.14
  
*/

 



answered Nov 8, 2016 by avibootz
0 votes
package javaapplication1;

public class JavaApplication1 {

    public static void main(String[] args) {

        Float fObj = 3.14f;
        System.out.println(fObj);
    }
}
   
/*
      
run:
      
3.14
  
*/

 



answered Nov 8, 2016 by avibootz
0 votes
package javaapplication1;

public class JavaApplication1 {

    public static void main(String[] args) {

        Float fObj = new Float(3.14);
        System.out.println(fObj);
    }
}
   
/*
      
run:
      
3.14
  
*/

 



answered Nov 8, 2016 by avibootz
0 votes
package javaapplication1;

public class JavaApplication1 {

    public static void main(String[] args) {

        Float fObj = new Float("1.199");
        System.out.println(fObj);
    }
}
   
/*
      
run:
      
1.199
  
*/

 



answered Nov 8, 2016 by avibootz

Related questions

3 answers 270 views
4 answers 332 views
332 views asked Nov 8, 2016 by avibootz
3 answers 254 views
3 answers 428 views
428 views asked Nov 8, 2016 by avibootz
3 answers 255 views
3 answers 298 views
298 views asked Nov 8, 2016 by avibootz
...