Answers for "fully qualified name in java"

0

Using java fully qualified name

//If you use fully qualified name then only declared class of this package will be accessible. Now there is no need to import. But you need to use fully qualified name every time when you are accessing the class or interface.

It is generally used when two packages have same class name e.g. java.util and java.sql packages contain Date class.

//save by A.java  
package pack;  
public class A{  
  public void msg(){System.out.println("Hello");}  
}  

//save by B.java  
package mypack;  
class B{  
  public static void main(String args[]){  
   pack.A obj = new pack.A(); // using fully qualified name  
   obj.msg();  
  }  
}
Posted by: Guest on August-31-2021

Code answers related to "fully qualified name in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language