Re: Another simple problem
From: Joona I Palaste (palaste_at_cc.helsinki.fi)
Date: 12/11/04
- Next message: Tilman Bohn: "Re: tomcat: how to release port 8080"
- Previous message: Joona I Palaste: "Re: Using reflection"
- In reply to: wislam: "Re: Another simple problem"
- Next in thread: Tilman Bohn: "Re: Another simple problem"
- Reply: Tilman Bohn: "Re: Another simple problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 11 Dec 2004 16:55:59 GMT
wislam <wislam@gmail.com> scribbled the following:
> What if you wanted a method called new() under Foobar obj?
> And I think it might add needless complexity to the compiler & code if
> you used: -
> Car car = new New();
> rather than
> Car car = new Car();
> no?
> How would you initialise the Car object? Same way as before?
> But then the Car() method call doesn't make sense.
> I guess you could do:
> car = new(toyota);
> Which I think is just as confusing (if not more so in the object) if
> you simply used the class name as the constructor.
I'm sorry, but you appear to have drawn conclusions from my post I never
intended. All I was proposing was changing the syntax of the constructor
declaration. Calling the constructor would remain the exact same as
before.
So if you had:
public class Car {
public new() {
/* ... */
}
public new(String model, int year) {
/* ... */
}
}
you would still call it with:
Car c1 = new Car();
Car c2 = new Car("Toyota", 1996);
-- /-- Joona Palaste (palaste@cc.helsinki.fi) ------------- Finland --------\ \-------------------------------------------------------- rules! --------/ "The trouble with the French is they don't have a word for entrepreneur." - George Bush
- Next message: Tilman Bohn: "Re: tomcat: how to release port 8080"
- Previous message: Joona I Palaste: "Re: Using reflection"
- In reply to: wislam: "Re: Another simple problem"
- Next in thread: Tilman Bohn: "Re: Another simple problem"
- Reply: Tilman Bohn: "Re: Another simple problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|