Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialSubham Singh
86 Pointsarray-based and collection-based APIs
I found this statement on Java doc can someone more clearly about calling them APIs and what are these APIs. What should I tell the interviewer If he asked me about APIs.
asList "This method acts as bridge between array-based and collection-based APIs"
2 Answers
Livia Galeazzi
Java Web Development Techdegree Graduate 21,083 PointsAn API is an application programming interface. Read about it here: https://en.wikipedia.org/wiki/Application_programming_interface Array-based and collection-based are broadly two ways to organize groups of objects in java. These two ways have different sets of specifications or expected behaviors. For example you can use the method "reverseOrder() " to reverse the order of members in any collection, be it a list, a set, or whatever (https://docs.oracle.com/javase/6/docs/api/java/util/Collections.html) whereas an array doesn't have a "reverseOrder()" method because it follows a different set of specifications. What the doc says is that you can use the "toList()" method to get around this kind of issue if you need to, by copying the array into a list (which is a collection). As for what kind of interview questions you might get on the topic, I'm sorry, I have no idea.
Livia Galeazzi
Java Web Development Techdegree Graduate 21,083 PointsI can see why you'd think but no, an interface isn't an API. Both can be thought of as a contract to help pieces of software work with each other, but an interface is more like a contract between two neighbors about the garden fence, while APIs are more like contracts between cities, or even countries, about trade routes and passports and so on. It's not the same scale. A Java API provides a whole set of features that can be used to communicate with other software. One example is the Java persistence API (JPA) which describes how to manage interactions with relational databases to persist data. Look here at the overview: it has several interfaces, one class, enums, annotations, exceptions... http://docs.oracle.com/javaee/6/api/javax/persistence/package-summary.html Another example, JavaMail to manage mails: http://docs.oracle.com/javaee/6/api/javax/mail/package-summary.html
Maybe have a look at this workshop: https://teamtreehouse.com/library/rest-api-basics It explains about REST APIs, which are APIs that follow a specific pattern and are useful to allow web applications to talk with each other. It's about a specific type of API, rather than all APIs, but will maybe help you understand what APIs are for.
See here for a list of Java APIs: https://en.wikipedia.org/wiki/List_of_Java_APIs
Subham Singh
86 PointsSubham Singh
86 PointsWill it be correct if I say that all Interfaces in Java are APIs?