Understanding Packages and Interfaces in Java
page 3 of 11
by Debjani Mallick
Feedback
Average Rating: 
Views (Total / Last 10 Days): 7844/ 271

Creating a Package

The statement that is used to create a package requires a keyword called “package” and the following syntax.

Listing 1

package packagename;

The package definition must be the first statement of the java program file. Suppose we have a program file named “Firstapplication.java” and we want to put it inside a package called Example, then the coding that would go inside is:

Listing 2

package Example;
public class Firstapplication 
{
      public static void main(String a[ ]) 
      {
            System.out.println("This is my first application");
      }
}

If package statement is not specified, all the classes are stored in a default unnamed package.


View Entire Article

Article Feedback

Title:  
Name:  
Url: ( Optional )
Comment:  
Please add 3 and 7 and type the answer here:

User Comments

Title: very nice elaboration   
Name: Regalla Naresh Reddy
Date: 6/10/2008 3:36:05 AM
Comment:
Its vey nice.If you include syntax and an exmaple on syntax looks very nice.So try it
Title: doubt   
Name: raghavendra
Date: 3/15/2008 3:01:11 AM
Comment:
i have created a package named account and i created a new folder name test inside test i written a java program to access the package account.. its saying package account not found.. kindly help me.. if any..
Title: very nice   
Name: antony
Date: 1/22/2008 6:14:33 AM
Comment:
its very very useful for beginers.so thanks for you.and also i want more in swing and awt etc
Title: Nice   
Name: Ed
Date: 8/12/2007 10:34:37 PM
Comment:
NICE ARTICLE
Title: Good work   
Name: Rick
Date: 8/10/2007 10:50:14 PM
Comment:
It is a good piece of work.
Title: I have not gone thru the article :)   
Name: Sandeep Acharya
Date: 8/10/2007 9:45:29 AM
Comment:
Hello,
How many articles do you have in pipeline?? Sorry, but I have not gone thru the article as I am sure I ll not get anything from that ;)...BTW carry on ur good work and whats abt the treat??? $ mein chk aaya ya nahin???

Product Spotlight
Product Spotlight 
Learn More
.NET Tools
asp.net shopping cart
asp.net chart control






Ads Powered by Lake Quincy Media
Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2008 ASPAlliance.com  |  Page Processed at 7/5/2008 1:03:11 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search