How can I create a new class instance from a class within a (static) class?

Posted by Mervin on Stack Overflow See other posts from Stack Overflow or by Mervin
Published on 2010-06-14T17:15:51Z Indexed on 2010/06/14 17:22 UTC
Read the original article Hit count: 274

Filed under:
|

I'm new to Java (have experience with C#),

This is what i want to do:

public final class MyClass
{
    public class MyRelatedClass
    {
      ...
    }
}

public class OtherRandomClass
{
    public void DoStuff()
    {
       MyRelatedClass data = new MyClass.MyRelatedClass(); 
    }
}

which gives this error in Eclipse: "No enclosing instance of type BitmapEffects is accessible. Must qualify the allocation with an enclosing instance of type BitmapEffects (e.g. x.new A() where x is an instance of BitmapEffects)."

this is possible in C# with static classes , how should it be done here?

© Stack Overflow or respective owner

Related posts about java

Related posts about android