Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Inner class instantiation
- From: Sunil.Mishra@xxxxxx (Mishra, Sunil)
- Subject: Inner class instantiation
- Date: Thu, 30 Sep 1999 11:24:45 -0400
You can do that... use "$" not "." for the InnerName... "." will try to look
in the subdirectory...
try Class.forName("com.Foo.Outer$Inner");
Sunil Mishra
Goldman Sachs,
sunilmishra@xxxxxxxxx
201-459-1185(R)
212-357-3922(O)
> -----Original Message-----
> From: Nick Rothwell [SMTP:NRothwell@xxxxxxxxxxx]
> Sent: Thursday, September 30, 1999 11:16 AM
> To: 'Advanced Java at Berkeley'
> Subject: Inner class instantiation
>
> Is there any reason why an inner class cannot be instantiated using
> Class.forName(name).newInstance()? The inner class is static (so it
> doesn't
> need an enclosing instance's context) and it is public, as is its
> enclosing
> class. With something like
>
> package com.Foo;
>
> public class Outer
> {
> public static class Inner { .... };
> }
>
> I should be able to instantiate a "com.Foo.Outer.Inner" but I'm getting
> ClassNotFoundError. The Java spec. suggests that this is the right naming
> convention (dotted separator between class names) but it's ambiguous with
> the package structuring, so maybe that's the problem?
>
> (As to why I'm doing this: it's in an internal testset, and I really want
> one file and class per test.)
>
>
> ---
> To unsubscribe, mail advanced-java-unsubscribe@xxxxxxxxxxxxxxxx
> To get help, mail advanced-java-help@xxxxxxxxxxxxxxxx
---
To unsubscribe, mail advanced-java-unsubscribe@xxxxxxxxxxxxxxxx
To get help, mail advanced-java-help@xxxxxxxxxxxxxxxx
- Prev by Date: Inner class instantiation
- Next by Date: interface vs. extending
- Previous by thread: Inner class instantiation
- Next by thread: interface vs. extending
- Index(es):