Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2012
    Posts
    3
    Rep Power
    0

    Default import java.util.* doesn't works

    Hi!

    import java.util.*;
    public class HelloDate1 {
    public static void main(String[] args) {
    System.out.println("Hello, it's: ");
    System.out.println(new Date());
    }
    }

    doesnt works!


    This is the error message:

    HelloDate1.java:6: cannot find symbol
    symbol : constructor Date()
    location: class Date
    System.out.println(new Date());
    ^
    1 error


    But if I change import java.util.* with import java.util.Date works!


    WHY?????


    Thank you so much!

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: import java.util.* doesn't works

    Do you happen to have your own class called Date that clashes with the java.util version? One that doesn't have a default constructor?

  3. #3
    Join Date
    Jan 2012
    Posts
    3
    Rep Power
    0

    Default Re: import java.util.* doesn't works

    I've changed my own class name in "Hello" but it doen't work again!

    The code I've posted is from the book: THINKING IN JAVA - Bruce Eckel

    It should work!

    Does it work on your own computer?


    Thanks!!!!!

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: import java.util.* doesn't works

    Quote Originally Posted by Martino Milani View Post
    I've changed my own class name in "Hello" but it doen't work again!
    I'm not talking about the current class you're working on. I'm asking if you have any other nearby classes that you've named "Date". Check your current package and have a look.

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is online now Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,415
    Rep Power
    20

    Default Re: import java.util.* doesn't works

    Nothing advanced about this. Moving to 'New to Java'

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  6. #6
    Join Date
    Jan 2012
    Posts
    3
    Rep Power
    0

    Default Re: import java.util.* doesn't works

    Problem solved!
    Thank you so much, FUBARABLE!!!!!

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: import java.util.* doesn't works

    Quote Originally Posted by Martino Milani View Post
    Problem solved!
    Thank you so much, FUBARABLE!!!!!
    You're welcome!

Similar Threads

  1. Obsolete Collection, import java.util.Hashtable
    By newbiejava in forum New To Java
    Replies: 2
    Last Post: 08-05-2010, 04:36 PM
  2. one works, mine doesn't
    By psychop in forum Java Applets
    Replies: 0
    Last Post: 01-25-2010, 11:36 PM
  3. import java.util ????
    By kris09 in forum New To Java
    Replies: 3
    Last Post: 08-11-2008, 12:39 AM
  4. java.util.DateFormat not found in import
    By christina in forum New To Java
    Replies: 2
    Last Post: 08-05-2007, 10:31 PM
  5. The import java.util.Scanner cannot be resolved
    By Heather in forum Advanced Java
    Replies: 1
    Last Post: 07-08-2007, 01:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •