freetimestudys@gmail.com          +91-7097633380
  Login Here                        

User defined packages:-

1) The packages which are declared by the user are called user defined packages.
2) In the single source file it is possible to take the only one package. If we are trying to take two packages at that situation the compiler raise a compilation error.
3) In the source file it is possible to take single package.
4) While taking package name we have to fallow some coding standreds.
Whenever we taking package name don’t take the names like pack1, pack2, sandhya, sri……… these are not a proper coding formats.
Rules to fallow while taking package name:-(not mandatory but we have to fallow)
1) The package name is must reflect with your organization name. the name is reverse of the organization domain name.
Domain name:- www.freetimestudy.com
Package name:- Package com.freetimestudy
2) Whenever we are working in particular project(Bank) at that moment we have to take the package name is as fallows.
Project name :- java
package :-Package com.freetimestudy.java 
3) The project contains the module (deposit) at that situation our package name should reflect with the module name also.
Domain name:- www.freetimestudey.com
Project name:- java
Module name:- package
package name:- Package com.freetimestudy.java.package 

package program

package com.freetimestudy
class Test
{
static void s(){
System.out.println("hi");
}
}

intput and output

output:Compilation : javac –d . Test.java com->freetimestudy->Test.class

Import session:-

The main purpose of the import session is to make available the java predefined support into our program.
Predefined packages support:-
Ex1:-
Import java.lang.String;
String is a predefined class to make available predefined string class to the our program we have to use import session.
Ex 2:-
Import java.awt.*;
To make available all predefined class present in the awt package into our program. That * represent all the classes present in the awt package.
User defined packages support:-
I am taking two user defined packages are

package program

import java.freetimestudy.*  //or import com.freetimestudy.Test
class pack{
public static void main(String args[]){
Test.s();
}
}

intput and output

output:hi