Eternal Nightmare
April 20, 2024, 05:09:52 am
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Breaking News: We Are Growing Fast. Keep Up The Good Work Guys
 
  Home Help Search Arcade Staff List Login Register  

Default constructor in java...

Pages: [1]
  Print  
Author Topic: Default constructor in java...  (Read 166 times)
0 Members and 1 Guest are viewing this topic.
svr2112
Starter
*

OWned +0/-0
Offline Offline

Posts: 29


« on: August 26, 2010, 12:10:15 pm »

While it's true right now you don't have a default constructor, it's wrong that the only way to get one is to remove your current one. Constructors, like pretty much everything else in Java, can be overloaded, meaning you can make multiple constructors that have different input arguments, and Java will select the constructor that matches the inputs.

In your case, you want to include something along the lines of:
public Date(){ //Whatever code you need }

In this example it looks like you're planning on having old = new Date(); have some sort of default values, so you can have your Date() constructor initialize those values. If you intend for Date() to call the Java default Date() constructor, you'll need to rename your class to something like MyDate and make sure it extends Date when you start it, so that you can call the super() constructor in the no-arg constructor.

____________

Funeral Insurance Funeral Cover
Report Spam   Logged

Share on Facebook Share on Twitter

david
Hero
*

OWned +0/-0
Offline Offline

Posts: 459


« Reply #1 on: May 22, 2012, 10:29:38 am »

There are a lot of geology books  on the market for people to choose from, covering topics which vary from scholarly discussions of fossils found in particular geological strata to topical books which are designed to familiarize travelers with the geology of a particular area. There are a number of things to think about when choosing geology books which will help people make the right decision. Since specialty books can be quite costly, it's a good idea to avoid making a mistake.
camisetas futbol | soccer kit | soccer shirts
« Last Edit: August 12, 2013, 11:39:15 am by david » Report Spam   Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by EzPortal
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum

Powered by SMF | SMF © 2016, Simple Machines
Privacy Policy