Random Class and DecimalFormat Class

Not a program but a quick question

Page 1 of 1

4 Replies - 1765 Views - Last Post: 12 January 2009 - 07:46 PM Rate Topic: -----

#1 s.thvlngm  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 18-December 08

Random Class and DecimalFormat Class

Post icon  Posted 12 January 2009 - 06:23 PM

1) The 'Random' class is found inside the util package or the java.util package?

2) The DecimalFormat class is found inside the util package or java.util package?

I put:

1) Java.util

2) util

Is it right?
Is This A Good Question/Topic? 0
  • +

Replies To: Random Class and DecimalFormat Class

#2 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8334
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Random Class and DecimalFormat Class

Posted 12 January 2009 - 06:29 PM

View Posts.thvlngm, on 12 Jan, 2009 - 05:23 PM, said:

1) The 'Random' class is found inside the util package or the java.util package?

2) The DecimalFormat class is found inside the util package or java.util package?

I put:

1) Java.util

2) util

Is it right?

Yes
No it is in text
so:

import java.util.Random;
import java.text.DecimalFormat;

Or the long name

java.util.Random ran = new java.util.Random();
java.text.DecimalFormat df = new java.text.DecimalFormat();
Was This Post Helpful? 0
  • +
  • -

#3 s.thvlngm  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 18-December 08

Re: Random Class and DecimalFormat Class

Posted 12 January 2009 - 06:32 PM

View Postpbl, on 12 Jan, 2009 - 05:29 PM, said:

View Posts.thvlngm, on 12 Jan, 2009 - 05:23 PM, said:

1) The 'Random' class is found inside the util package or the java.util package?

2) The DecimalFormat class is found inside the util package or java.util package?

I put:

1) Java.util

2) util

Is it right?

Yes
No it is in text
so:

import java.util.Random;
import java.text.DecimalFormat;

Or the long name

java.util.Random ran = new java.util.Random();
java.text.DecimalFormat df = new java.text.DecimalFormat();


Ok sir, correct me if I am wrong of course but...

Random belongs to Java.util package

and

DecimalFormat belongs to java.text package?

In my Comp. Sci. notes for the random class it says that

"The Random class is part of the Java library and belongs with a group of other classes to the util package, which in turn belongs to the java package."

Does this mean random belongs to just util package or java.util package since it is util belongs to java?
Was This Post Helpful? 0
  • +
  • -

#4 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8334
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Random Class and DecimalFormat Class

Posted 12 January 2009 - 07:37 PM

View Posts.thvlngm, on 12 Jan, 2009 - 05:32 PM, said:

[Ok sir, correct me if I am wrong of course but...

Random belongs to Java.util package

and

DecimalFormat belongs to java.text package?

In my Comp. Sci. notes for the random class it says that

"The Random class is part of the Java library and belongs with a group of other classes to the util package, which in turn belongs to the java package."

Does this mean random belongs to just util package or java.util package since it is util belongs to java?


Think has "package" as "directory"

Random is in the java.util directory not in the java.util.directory
When you import you always import a package so you import the packageName not the packageName.package

#import java.util.*;

imports all the package java.util
Hopes it's clearer
Was This Post Helpful? 0
  • +
  • -

#5 s.thvlngm  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 18-December 08

Re: Random Class and DecimalFormat Class

Posted 12 January 2009 - 07:46 PM

View Postpbl, on 12 Jan, 2009 - 06:37 PM, said:

View Posts.thvlngm, on 12 Jan, 2009 - 05:32 PM, said:

[Ok sir, correct me if I am wrong of course but...

Random belongs to Java.util package

and

DecimalFormat belongs to java.text package?

In my Comp. Sci. notes for the random class it says that

"The Random class is part of the Java library and belongs with a group of other classes to the util package, which in turn belongs to the java package."

Does this mean random belongs to just util package or java.util package since it is util belongs to java?


Think has "package" as "directory"

Random is in the java.util directory not in the java.util.directory
When you import you always import a package so you import the packageName not the packageName.package

#import java.util.*;

imports all the package java.util
Hopes it's clearer



Oh... I understand now... its way clearer.. thanks for all your help pbl
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1