Question:
What are packages in java??? please help?
Uthaiah S
2011-10-13 04:03:53 UTC
I am a beginner in java and currently I am referring Complete Reference to learn java.
My problem is I finished learning how to create class(s) within one file and also I know how to inheritence within a file(Since i already knowC++), But i wanted to know
*What are packages and their use .
*How to create them.
*What is the use accces specifier while using package.


Please give any simple examples of how to create a package and how to use in main program.

Plese help... I am not able to understand packages in Complete refrence:(

Thanks all in advance....
Five answers:
2011-10-13 04:09:20 UTC
Package is like folder which contains classes.



Set of Classes.



add line



package com.java;



all classes below will be added in this package.



Ready made libraries also available in Java.

to use them you have to import them.

like

import com.java;
2011-10-13 21:52:17 UTC
Packages means just as folders

It holds a group of classes and interfaces.

we can avoid name collision using Packages....means if you have same name for two classes

that you can put them in different packages....



and to learn how to create package and using it in you program follow the link below:-
2011-10-13 04:32:03 UTC
To be short , Package is how you "Organize" your source code in folders.



A more detailed & excellent information on packages are given here. Examples are simple & effective. I suggest it as worth to read..



URL: http://download.oracle.com/javase/tutorial/java/package/index.html



Definition: "Packages are a feature of the Java programming language that help you to organize and structure your classes and their relationships to one another."



You can have a read on wikipedia link too : http://en.wikipedia.org/wiki/Java_package
jonah k
2011-10-13 04:17:57 UTC
*Packages are useful when you are creating two projects which are of the same name.Obviously you can't put them in the same folder otherwise one is bound to get replaced .But if u use packages then two projects of the same name can exist in the same work space.



*To create packages just specify the name of the package at the beginning of the project.

eg- package

2016-12-05 07:59:21 UTC
i'd ought to assert specific I do look at his kit. the terrific is equipped denims. yet evaluate that even nonetheless we look at the kit maximum persons have sufficient undemanding sense to appreciate that its what interior that counts. inspite of the shown fact that it does get the ball rolling. lol


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...