CrazyEngineers
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Neeraj Sharma

    MemberJul 31, 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.
    Are you sure? This action cannot be undone.
    Cancel
  • Alok mishra

    MemberSep 3, 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 .
    Are you sure? This action cannot be undone.
    Cancel
  • Anoop Kumar

    MemberSep 3, 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 #-Link-Snipped-# . 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.
    Are you sure? This action cannot be undone.
    Cancel
  • Alok mishra

    MemberSep 3, 2013

    Yes its a way of implementing ABSTRACTION
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register