• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Question about import

Bee Torika

Newbie
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..


Thanks.
 
Last edited by a moderator:
Well I think it's good to import specific classes, to avoid possibly the same class name in different packages.
 
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
 
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.
 
Back
Top Bottom