![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Mar 2007
Posts: 4
Rep Power: 0
![]() |
Java programing any ideas????Please help
Complete the condition in the if statement below so that it will be true when the date in the GregorianCalendar instance myGC1 is not later than the date of the GregorianCalendar instance myGC2:
if ( ) { ... } ![]() |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
:beard: :eek: :beard: :eek: :beard:
![]()
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Mar 2007
Posts: 4
Rep Power: 0
![]() |
??? if this is so easy for you could you help me????
|
|
|
|
|
|
#4 |
|
Newbie
Join Date: Mar 2007
Posts: 4
Rep Power: 0
![]() |
I'm doing this like that
myGC1.compare(myGC2)<=0 Test 1 succeeded (0 marks): The expected output was produced correctly. Test 2 succeeded (0 marks): The expected output was produced correctly. Test 3 failed (exit code = 1): Main.java:35: cannot find symbol symbol : method compare(java.util.Calendar) location: class java.util.Calendar return (myGC1.compare(myGC2)<=0 ); ^ 1 error Test 4 failed (exit code = 1): Exception in thread "main" java.lang.NoClassDefFoundError: Main |
|
|
|
|
|
#5 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Look at the error that you get. It says that it "cannot find symbol" and that this symbol is "method compare". In other words, it can't find a method called "compare" on your Calendar object.
Next look up the Calendar class (from which GregorianCalendar derives), on Sun's online Java documentation. Usually you can just type the full class name (java.util.Calendar) into Google and it'll find the right page for you without having to figure out where Sun's search engine is. Look through the Calendar documentation. It doesn't have a "compare" method, which explains why your Java compiler couldn't find it. There is, however, a "compareTo" method, and a "before" and "after" method. See? Simple when you know how ![]() |
|
|
|
|
|
#6 |
|
Newbie
Join Date: Mar 2007
Posts: 4
Rep Power: 0
![]() |
I still don't know how to do this
Calendar now = Calendar.getInstance(); ![]() |
|
|
|
|
|
#7 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
You don't explain what you want to do. It's always helpful to explain what you want to do, rather than posting an incorrect line of code and expecting people to know what it is you want to do.
However, I'd guess that you want to create a new Calendar instance. You can't create a new Calendar object, because Calendar is an abstract class. There are several different calendar systems around, and you need to tell Java which one you want. The standard calendar system in use today is the Gregorian Calendar, and that's the one you're told to use. So: Calendar now = new GregorianCalendar(); GregorianCalendar now = new GregorianCalendar(); |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Programming with Java: Tutorial | ReggaetonKing | Java | 7 | May 20th, 2008 10:58 AM |
| Special browser in Java (Project) | stalefish | Java | 3 | Feb 9th, 2008 4:22 PM |
| First Java Program | duale2005 | Java | 3 | May 22nd, 2006 5:17 PM |
| Java programmers, game developers, artists, be ware! RPG game team is recruiting! | atcomputers.us | Paid Job Offers | 7 | Sep 25th, 2005 7:25 PM |
| Begin my first lesson to learn Java | satimis | Java | 7 | Mar 3rd, 2005 2:45 AM |