public class StringNumberToDecimal {
public static void main(String[] args) {
String string = "10";
float decimalValue = Float.parseFloat(string);
System.out.println(decimalValue);
}
}
package org.arpit.java2blog;
import java.text.DecimalFormat;
public class FormatNumberWithCommaDecimalFormat {
public static void main(String[] args) {
DecimalFormat df=new DecimalFormat("#,###.00");
double d = 2000000;
String formattedNumberWithComma = df.format(d);
System.out.println("Formatted number with commas: "+formattedNumberWithComma);
}
}