java - Why do we need to import a class if the parent already imports it -


say have:

import android.os.bundle; import android.app.activity;  public class myactivity extends activity {      @override     public void oncreate(bundle b) {      } } 

and extend class such:

public class mynewactivity extends myactivity {      @override     public void oncreate(bundle b) {      } } 

if don't include import android.os.bundle; mynewactivity class won't compile, should know bundle since parent class imports it. gives?

in java, scope of import not class declared, file in import given. so, in different file, must still import need.

according jls, section 7.5,

an import declaration makes types or members available simple names within compilation unit contains import declaration.

that is, scope of import file within it's located.


Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -