Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
  #1  
Old October 2nd, 2002, 05:56 PM
Santos Santos is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2001
Posts: 29 Santos User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 31 m 59 sec
Reputation Power: 0
Java Declaration

I m hoping someone can pseudo code the following declaration, to clear things in my head:

========================

Calendar startTime = new GregorianCalendar();

========================

Am I right in saying the above snippet means the following:

make 'startTime' an Object of the method 'GregorianCalendar' which is in the ' Calendar ' api?

Thanks for all help,

Santos

Reply With Quote
  #2  
Old October 4th, 2002, 03:30 AM
gaspacho soup gaspacho soup is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 5 gaspacho soup User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to gaspacho soup Send a message via AIM to gaspacho soup
err, that seems very wrong to me.

Calendar startTime = new GregorianCalendar();

should be
Calander startTime = new startTime()

you cannot replace an object with a method!

Reply With Quote
  #3  
Old October 4th, 2002, 04:32 AM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
Eh.... Yes, well, here's the answer:

There is a class called Calendar. It's an abstract class, which means you can't actually *make* a Calendar object. It has a subclass, though, called GregorianCalender. Now, GregorianCalendar is still a Calendar, ie: anything a Calendar can do a GregorianCalendar can do too. A GregorianCalendar has been extended, though, to include extra functionality.

So here's what your code is saying:

Make a new Calendar object, called startTime, using the GregorianCalendar class.

Creating an object this way means that the Java compiler will recognize startTime as a Calendar, so if you try to call methods from the GregorianCalendar class you'll get a compiler error. You can cast startTime to a GregorianCalendar object, though, if you need those methods.

A note about default constructors:

Calendar startTime = new GregorianCalendar();

GregorianCalendar() is a function of the GregorianCalendar class that basically says "Make a new object". It has no arguments and has the same name as the class. It's called a default constructor, and every class has one.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Java Declaration


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway