Jump to content

Shortcut to create instance of object?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
Sinipull

Sinipull

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 386 posts
Does anyone know if it's possible to implement my own "shortcut" to creating an instance of object?
for example:
Integer i = 3;
which is a strange way to instance an Object. Is this just strictly made to primitive wrappers, or can i implement it to my own classes somehow?

#2
dbug

dbug

    Programmer

  • Members
  • PipPipPipPip
  • 155 posts
As far as I know, Java does not allow to invoke constructors implicitly for normal classes. You must use the new keyword.