Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
array-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"
An 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.
I 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