Sorry for my ignorance but the problem I have is probably so simple that I cannot seem to find an answer for it.
I am just learning about the Java.Util Package but in following my course module I am getting an error.

here is the simple code :

import java.util.*;

public class Main {

      public static void main(String[] args) {
            Calendar c = new Calendar.[U]getInstance();[/U] 


now here is the error:

Exception in thread "main" java.lang.RuntimeException: Uncompilable source code
        at javautilpack2.Main.main(Main.java:19)
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)

the get.Instance is underlined (red) (netbeans)
My reckoning is that for some reason the Calendar class cannot be found? or the method?
Sorry people normally I would be able to find the problem if it was just the code but unfortunately I have not come accross this kind of error in my course yet.

Recommended Answers

All 4 Replies

you need to import the util calender

import java.util.Calendar;

One more thing ( there is no new in getInstance)

Calendar c = Calendar.getInstance();

did someone know how to pix this error document.write("Smart Tag Error: Malformed URL - ST_REJECTED_QUERY_STRING ");

Oh I cannot believe I missed that, I am sorry for waisting your time thank you for that. It was the "new" where the problem was, I had already tried to import the calendar only.

Thanks again,

I promise to look closer next time :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.