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


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

This is what is I want do:

  public final category MyClass {public class MyRelatedClass {...}} public class Other RandomClass {Public Zero DoStuff () {MyRelatedClass Data = New MyClass.MyRelatedClass (); }}  

which gives this error in the eclipse:

Any type of bitmapfile is not accessible to type. It is necessary to qualify allotment with a periodic example of bitmapEffects (egxnew A (where is an example of x bitmapifiers).

It is possible with static classes in C #, how should it be in response to comments about packaging of several classes in a file: Unlike the .net, most of Java's In the implementation, a strict correlation between public class names and file type names is implemented. This is not a tough requirement, but the system is not used where the relation does not apply JLS - it says:

When in a file system (§7.2.1) If the package is submitted, the host system may choose to apply the restriction that this is a compile-time error if not in the name of a single extension (such as .java or .jav) in a file name under type name If any of the following is found Is:

  • type is referred to
  • This type is declared public (and therefore potentially available from the address in the second package).

Check the question then:

If you are looking to create a namespace to add to your respective classes, Need to use what you need. Static declaration does not mean an instnace - they can still be instantiated - static means that they can be instantiated without reference to the enclosed class. As the enclosed class is just for the group, and not the data, you are safe by making it stable, to make it clear that the enclosed class is only for the group, you declare it as the interface So that it can not be done immediately and there is no description of the details.

Although personally, I would like to avoid doing this - in Java, the package names are used to implement it, using internal classes is cumbersome as soon as possible (I Have tried!)


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -