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 = ImageIO.read(barCodeInputStream);
LuminanceSource source = new BufferedImageLuminanceSource(barCodeBufferedImage);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
06.
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
3.6k views

Related Posts

@Kaustubh Katdare · Apr 18, 2016

NIT Sikkim's got the fastest supercomputer among all the 31 NITs (National Institute Of Technology) in India. Titled "Param Kanchenjunga", the supercomputer has been developed by teams from NIT Sikkim...
2.5k views

@MANAN BOTHRA · Mar 30, 2016

Project Abstract / Summary : The project is about making the energy meter smart by having a continuous automatic communication between the consumer’s energy meter and the utility. The energy...
5.5k views

@Kaustubh Katdare · Jul 17, 2013

Lenovo Ideapad A1000 price in India is Rs. 8999, as listed on the 'Do Store'. We decided to have an overview of the specs and feature this tablet offers and...
2.2k views

@Kaustubh Katdare · Jan 30, 2013

This review is dedicated to Sendy - the best email marketing software I accidentally found on the Internet and have been using for several weeks now. Sendy is self-hosted email...
2.9k views