CrazyEngineers Archive
Old, but evergreen and popular discussions on CrazyEngineers, presented to you in read-only mode.
@aarthivg • 01 Aug, 2013
1.The classes contained in the packages of other programs can be easily reused. Is there any other benefits of packages in JAVA.
I also, came across "Packages also provide a way for separating design from coding". Can anyone explain me the above line.

2. What is the difference between Java API and user defined packages in JAVA
@Neeraj Sharma • 01 Aug, 2013 As far as I know

For 2nd question: There is no specific difference between Java API and user defined packages. It is just that when a user creates a package for carrying out a particular task (for example, Biometric scanning) and wants to distribute it to others so that they can directly use the package for similar applications, we call it an API.

For 1st question: I think that itself is the sole purpose of packages and that is to reuse the classes. As far as separation of design and coding goes, design is just the structure or a blueprint of a class or method in the package definition. We specify the task that is going to be performed by these class definitions of the package by overriding them and writing code in the actual program where we are using the package. That is how you can say that you are separating design from coding.
@Alok mishra • 04 Sep, 2013 APIs are like a layer between your code and data to be processed . For example you have created a class -Maxnumber , in which you defined a method -getmax(int[] arr) , which takes an array of integers as parameter and results the largest Number among them and you placed this class in a package 'findmax' . Now ever again if u want to find maximum element from a given array then dont rewrite the logic code just make a new class and import that package - import findmax.* ; , create object of the class Maxnumber , then using that object call the method i.e. getmax(arr2) passing a reference to an array and you'll get the maximum number by using your smallest API . You can give it to others and it'll help them find maximum element of any integer array .
@Anoop Kumar • 04 Sep, 2013 API are group of classes to do certain job. in general practice you will just all an api via single point of call.
For example Google for Java barcode scanner api . you will use this api by following fashion.
InputStream barCodeInputStream = new FileInputStream("file.jpg");
BufferedImage barCodeBufferedImage =;
LuminanceSource source = new BufferedImageLuminanceSource(barCodeBufferedImage);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
In above code you don't have to bother about what the classes are there in api package (.jar file) and how it's done.

Package/user defined package is just a mean of grouping classes together so developer get to know that this class is belong to this group (package) some times packages are also use to separate layer of project. like action classes in one package and DTO (data transfer objects are in another).
Developer call these classes individually as required.
@Alok mishra • 04 Sep, 2013 Yes its a way of implementing ABSTRACTION

Related Posts

@Ankita Katdare · Nov 27, 2013

After being a part of lots of rumors and a series of leaks, Nokia Inc. has finally launched its much talked about smartphone - the Nokia Lumia 525. A successor...

@Kaustubh Katdare · Aug 27, 2009

Here's a brand new seminar topic for all of you - HTML 5 ! There's plenty of information for you available on the Internet. Following references might be useful to...

@PraveenKumar Purushothaman · Mar 2, 2011

Day of the Week: January has 31 days. It means that every date in February will be 3 days later than the same date in January (28 is 4 weeks...

@Rxwdll · Jan 8, 2013

My DAC rank is 2899 and i got VITA Mumbai in my first round counselling....... (Not even expected to get DAC with this Rank). so confused. there is a lot...

@imgopi · Sep 4, 2011

Hi am fresher doing btech(cse) i want to join in infosys plz help me to get success in interview.