naming a package java
//if your domain name is google.com, name your package as com.google so that your package is unique across the world as domain names are unique
package com.google
naming a package java
//if your domain name is google.com, name your package as com.google so that your package is unique across the world as domain names are unique
package com.google
Using java packagename.*
//If you use package.* then all the classes and interfaces of this package will be accessible but not subpackages.
The import keyword is used to make the classes and interface of another package accessible to the current package.
//save by A.java
package pack;
public class A{
public void msg(){System.out.println("Hello");}
}
//save as B.java
package mypack;
import pack.*; //Importing the package named pack which contains class A.
class B{
public static void main(String args[]){
A obj = new A();
obj.msg();
}
}
naming a package java
//if your domain name is google.com, name your package as com.google so that your package is unique across the world as domain names are unique
package com.google
Using java packagename.*
//If you use package.* then all the classes and interfaces of this package will be accessible but not subpackages.
The import keyword is used to make the classes and interface of another package accessible to the current package.
//save by A.java
package pack;
public class A{
public void msg(){System.out.println("Hello");}
}
//save as B.java
package mypack;
import pack.*; //Importing the package named pack which contains class A.
class B{
public static void main(String args[]){
A obj = new A();
obj.msg();
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us