Link to home
Start Free TrialLog in
Avatar of rgb192
rgb192Flag for United States of America

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);

    }
}

Open in new window




numberformatting

is this an existing class

why do I not need a NEW keyword

numberFormat object=new numberFormat()
ASKER CERTIFIED SOLUTION
Avatar of CPColin
CPColin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of mccarl
mccarl
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@rgb192,

Do you have any further questions on this subject, or are you happy with the above comments?
Avatar of rgb192

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).