Home Tutorial Java Certification Local Variable ,Package & import

 
 

Share on Google+Share on Google+
Local Variable ,Package & import
Posted on: July 5, 2010 at 12:00 AM
Advertisement
In this SCJP Section, you will learn about Local Variable ,Package & import of java

Local Variable ,Package & import

A local variable has a local scope.Such a variable is accessible only from the function or block in which it is declared.

Example of Local variable :

The class variable are declared in the class but not within methods of any class. Whereas the local variable exits within the methods of any class. Below two program are shown which help you to understand the difference between the class and local variable :

Showing Local Variable


public class LocalVar {
public static void main(String args[]) {
int localvariable = 101;
System.out.print(localvariable);
}
}

Showing the Class Variable

public class ClassVar {
private static int classVariable;

public static void main(String args[]) {
classVariable = 101;
System.out.print(classVariable);
}
}

Package & import

Java classes can be grouped together in packages. A package name is the same as the directory (folder) name which contains the .java files. You declare packages when you define your Java program, and you name the packages you want to use from other libraries in an import statement.

For More Details Click Below :

Package & import

The Package Keyword

Create Your Own Package

Advertisement

Related Tags for Local Variable ,Package & import:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 5, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com