Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #848

Re: Instantiation of a class

From Eric Sosman <esosman@ieee-dot-org.invalid>
Newsgroups comp.lang.java.help
Subject Re: Instantiation of a class
Date 2011-07-11 21:57 -0400
Organization A noiseless patient Spider
Message-ID <ivg9md$c1c$1@dont-email.me> (permalink)
References <d98a873f-d5db-4243-be26-2109c25744b2@q12g2000prb.googlegroups.com>

Show all headers | View raw


On 7/11/2011 7:03 PM, Fred wrote:
>
> I'm thinking about statements like String foo = new String("foo");
> When is the constructor specified not the name of the type of
> reference variable?

     Aside: The example is sort of silly, because one seldom needs
two instances of the same String.

     At the risk of answering a homework question, I can think of
two situations in which `x = new Y(...)' works even though x does
not have type Y.  First, x's type may be that of one of Y's
superclasses, or of an interface implemented by Y.  Second, the
class that's instantiated might not have a name the Java source
code can speak.

     And maybe the gurus will think of additional possibilities.

-- 
Eric Sosman
esosman@ieee-dot-org.invalid

Back to comp.lang.java.help | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Instantiation of a class Fred <albert.xtheunknown0@gmail.com> - 2011-07-11 16:03 -0700
  Re: Instantiation of a class lewbloch <lewbloch@gmail.com> - 2011-07-11 16:41 -0700
    Re: Instantiation of a class lewbloch <lewbloch@gmail.com> - 2011-07-11 16:54 -0700
  Re: Instantiation of a class Mayeul <mayeul.marguet@free.fr> - 2011-07-12 02:02 +0200
  Re: Instantiation of a class Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-07-11 21:57 -0400
    Re: Instantiation of a class Patricia Shanahan <pats@acm.org> - 2011-07-11 19:02 -0700
      Re: Instantiation of a class Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-07-11 22:10 -0400
    Re: Instantiation of a class Fred <albert.xtheunknown0@gmail.com> - 2011-07-11 20:29 -0700
      Re: Instantiation of a class lewbloch <lewbloch@gmail.com> - 2011-07-12 14:35 -0700
    Re: Instantiation of a class Gene Wirchenko <genew@ocis.net> - 2011-07-11 21:25 -0700
      Re: Instantiation of a class Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-07-12 07:47 -0400
        Re: Instantiation of a class lewbloch <lewbloch@gmail.com> - 2011-07-12 11:09 -0700

csiph-web