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 273 views
4 answers 333 views
333 views asked Nov 8, 2016 by avibootz
3 answers 258 views
3 answers 430 views
430 views asked Nov 8, 2016 by avibootz
3 answers 259 views
3 answers 299 views
299 views asked Nov 8, 2016 by avibootz
...