- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Float Wrapper Class
Float is a wrapper class provided to wrap float primitive value.
Let us create a Float object with float primitive.
// float primitive float myFloat = 24.22f; // Float object Float obj1 = new Float(myFloat);
Let us now create a Float object from string.
Float obj2 = new Float("39.87");
The following is an example that displays both the ways discussed above with output.
Example
import java.lang.*; public class Demo { public static void main(String args[]) { float myFloat = 24.22f; Float obj1 = new Float(myFloat); System.out.println(obj1); Float obj2 = new Float("39.87"); System.out.println(obj2); } }
Output
24.22 39.87
- Related Articles
- Which packages contain Wrapper class in Java?
- Why do we need a wrapper class in Java?
- How to convert primitive data into wrapper class using Java?
- What is the number wrapper class and its methods in Java?
- What is the character wrapper class and its methods in Java?
- Explain wrapper classes in Java?
- Bootstrap 4 .float-right class
- Bootstrap 4 .float-left class
- Bootstrap 4 .float-none class
- What are wrapper classes in Java?
- Primitive Wrapper Classes are Immutable in Java
- Useful Methods in Float Class in Ruby
- Java Float isNaN() Method
- Java Float isInfinite() Method
- Wrapper Clothing

Advertisements