By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,237 Members | 1,228 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,237 IT Pros & Developers. It's quick & easy.

new Class in constructor

P: 679
  1. Expand|Select|Wrap|Line Numbers
    1. public class Expression implements IExpression{
    3. public Expression(){} 
    4. public Expression(new DotExpression()){}}
why for
Expand|Select|Wrap|Line Numbers
  1. public Expression(new DotExpression()){}
i get illigal start of type

Thank You
Oct 16 '13 #1
Share this Question
Share on Google+
1 Reply

Expert 2.5K+
P: 3,112
You get an error there because you can't put objects into a signature.

Basically, every time you call a method (and a constructor is a kind of method) you can pass any object you like as long as it fits the signature of that function. But when defining a signature it may only contain modifiers (public, final, static, etc.), a type (if it's no constructor), a name and a list of parameter types and names.
Oct 16 '13 #2

Post your reply

Sign in to post your reply or Sign up for a free account.