1. Are you ready for the Galaxy S20? Here is everything we know so far!

Question about import

Discussion in 'Android Development' started by Bee Torika, Feb 8, 2016.

  1. Bee Torika

    Bee Torika Newbie
    Thread Starter

    I have to import those three classes.

    import android.graphics.Color;

    import android.graphics.Paint;

    import android.graphics.Canvas;

    And I will simply import all of that by

    import android.graphics;

    So, I have a question.

    Why a developers import each of them one by one ?

    Why not just import like import android.graphics; ?

    This way will take much more time and memory ?

    Oh, I know this is basic question, but I want to know a reason..


  2. Best Answer:
    Post #2 by Deleted User, Feb 8, 2016 (1 points)

    1. Download the Forums for Android™ app!


  3. Deleted User

    Deleted User Guest

    #2 Deleted User, Feb 8, 2016
    Last edited by a moderator: Feb 8, 2016
    Mikestony, Bee Torika and scary alien like this.
  4. Bee Torika

    Bee Torika Newbie
    Thread Starter

    I see, so prevent duplicate method name (name space issue) , right ?
  5. Deleted User

    Deleted User Guest

    Well I think it's good to import specific classes, to avoid possibly the same class name in different packages.
    Bee Torika likes this.
  6. HeavensSentSword

    HeavensSentSword Well-Known Member

    Doesn't it keep the whole project smaller to? If you are using only one method from a lib then why import the whole thing if you just want one method from a .somthingorother
  7. Deleted User

    Deleted User Guest

    It's probably more efficient to import specific classes, but in terms of class loading, then the JVM only imports what it needs at runtime. I don't think it actually makes a whole lot of difference tbh.
    HeavensSentSword likes this.

Share This Page