rgb192
asked on
new keyword in numberFormat class
package com.example.java;
import java.text.NumberFormat;
public class Main {
public static void main(String[] args) {
int R = 42;
String fromR = Integer.toString(R);
System.out.println(R);
boolean Rb = true;
Boolean.toString(Rb);
System.out.println(Rb);
long Rl = 100_000;
//Long.toString(Rl);
NumberFormat formatt = NumberFormat.getNumberInstance();
String formatted = formatt.format(Rl);
//with commas instead of underscore
System.out.println(formatted);
}
}
numberformatting
is this an existing class
why do I not need a NEW keyword
numberFormat object=new numberFormat()
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
so it is static and what is class under it in the factory
The exact implementation class is unknown. It's only known that it implements the NumberFormat interface (which is what you should be programming to, anyway).
Do you have any further questions on this subject, or are you happy with the above comments?