Search code examples
javaandroid-studiolibrariesandroid-studio-2.0

Why is required to define a new class when I create a new Java module in Android Studio?


When we create a new java lib module in Android Studio, it's mandatory to provide a name for the java class. I never know what to give, since it's not common to have a central class in a library. What is the purpose of this class?

enter image description here


Solution

  • When you are creating a java module, you are basically creating a java file - which will (obviously) contain java code.

    The minimal structure of a java code (ClassA.java file as example) is like this:

    // your imports
    
    public class ClassA{
    
        // variables and methods inside ClassA
    
    } // end of ClassA
    

    The code (ClassA.java file) might contain additional classes - but it must contain at least one public class.

    In the dialog box shown in your question, you are asked to provide the name of the public class which will be in the java module.