Calendar help - who is wrong, me or Netbeans?
I want to set a couple of dates on Calendars and do a couple of very simple things with them, but I can't even seem to set a date.
I have this:
"package pointscalculator;
import java.util.*;
public class Week {
Calendar startDate = Calendar.getInstance();
startDate.set(2012,6,21,0,0);
...[other code]......"
Netbeans reckons that this is illegal, but in both the books I have this should work.
The Netbeans error:
"package startDate does not exist
<identifier> expected
illegal start of type"
I can't work out what I've done wrong. Or has my Netbeans spazzed out in some crappy way?
Re: Calendar help - who is wrong, me or Netbeans?
Take netbeans out of the picture- compile via the command prompt. Do you still get the error? If so, it's your fault. If not, it's netbeans's fault.
If it is indeed your fault (and I expect it is), you should put together an SSCCE that demonstrates the problem.
Re: Calendar help - who is wrong, me or Netbeans?
I also moved this thread, as it doesn't directly deal with Collections or generics.
Re: Calendar help - who is wrong, me or Netbeans?
Why are you calling methods (startDate.set(2012,6,21,0,0);) outside of a constructor or method? That is probably what it is complaining about.