- 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 Program to convert string value to float using Float.valueOf()
The Float.valueOf() method is used in Java to convert string to float.
The following are our string values.
String str1 = "100.5"; String str2 = "200.5";
To convert the string value to float, try the method valueOf()
float val1 = (Float.valueOf(str1)).floatValue(); float val2 = (Float.valueOf(str2)).floatValue();
The following is the complete example with output.
Example
public class Demo { public static void main(String args[]) throws Exception { String str1 = "100.5"; String str2 = "200.5"; float val1 = (Float.valueOf(str1)).floatValue(); float val2 = (Float.valueOf(str2)).floatValue(); System.out.println("Multiplication = " + (val1 * val2)); } }
Output
Multiplication = 20150.25
- Related Articles
- Java Program to convert float to String
- Java Program to convert Java String to Float Object
- Java Program to convert a String to a float type Number
- Convert from float to String in Java
- Convert from String to float in Java
- Java Program to convert an int value to String
- Java program to convert float decimal to Octal number
- Java Program to convert String to Integer using Integer.parseInt()
- Java Program to convert Java Float to Numeric Primitive Data Types
- Java Program to convert a Primitive Type Value to a String
- Haskell Program to Convert String value to byte Value
- Golang Program to Convert String Value to Byte Value
- Convert string to integer/ float in Arduino
- Convert tuple to float value in Python
- Convert double value to string in Java

Advertisements