Help Java novice

Reply

Join Date: Oct 2006
Posts: 2
Reputation: sarahavickers is an unknown quantity at this point 
Solved Threads: 0
sarahavickers sarahavickers is offline Offline
Newbie Poster

Help Java novice

 
0
  #1
Oct 26th, 2006
Hi All,

I am a total java novice and i am having a real problem running the following code:
  1. import java.util.*;
  2.  
  3. public class Methods
  4. {
  5. public static void main( String [] args)
  6. {
  7.  
  8. Date independenceDay = new Date ( 7, 4, 1776 );
  9. int independenceMonth = independenceDay.getMonth();
  10. System.out.println("Independence day is in month " + independenceMonth);
  11.  
  12.  
  13. Date graduationDate = new Date (5, 15, 2008);
  14. System.out.println("The current day for graduation is " + graduationDate.getDay() );
  15.  
  16. graduationDate.setDay(12);
  17. System.out.println( "The revised day for graduation is " + graduationDate.getDay() );
  18. }
  19. }
This is actually from a book i am working through and if it isn't working i was wondering if there was something wrong with the code or my pc.

The error message reads:

1 error found:
File: C:\Documents and Settings\Steven\Desktop\Methods.java [line: 16]
Error: cannot find symbol
symbol : method setDay(int)
location: class java.util.Date


Please help

Thanks
Sarah
x
Last edited by cscgal; Oct 27th, 2006 at 12:51 pm. Reason: [code=java] [/code] tags added
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 229
Reputation: DavidRyan is an unknown quantity at this point 
Solved Threads: 11
DavidRyan's Avatar
DavidRyan DavidRyan is offline Offline
Posting Whiz in Training

Re: Help Java novice

 
0
  #2
Oct 26th, 2006
First of all, many of the methods in the Date class is depreciated. They are still implemented, but the Calendar class fills the same niche better.

As for your actual problem, you'd be after the setDate(int) method.

Check you the Java API if you haven't already.
Please anyone, correct me if I am wrong. It is the best way for me to learn.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,189
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 483
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is online now Online
Code tags enforcer

Re: Help Java novice

 
0
  #3
Oct 29th, 2006
There is no setDay() method in the Date Class, this mean your book must be old and you will get more similar problems...
Follow the link which David give it to you, in packages find java.util, then bellow find Date and read trough
I use now Deitel&Deitel JAVA How to Program 6th edition
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC