Finding your way around the JAVA API?

Hello,

I have a programming exam coming up in a few days where we'll be using the Java API. However, I still don't understand how to navigate it. How can I find out which methods are relevant for my needs and where they are located? For example, I need a method to determine the type of an object (getType()). How could I find this method specifically in the API?

(2 votes)
Loading...

Similar Posts

Subscribe
Notify of
5 Answers
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
regex9
10 months ago

First, consider which type the object you want to change in the state.

In your example, you could either see if the possible types of the variable correspond to any type from the SE or you can look into the Object-Class (always all Java classes inherit from Object).

In the API reference, the easiest and fastest way is to search. Otherwise you could also navigate if you know the SE structure at least something: Object– Class is in java.base– Module and there of course in java.lang-Package.

On the overview page of the class there is a classification in sections for fields, methods, etc. Under the tabular list of available methods there is a simple list of inherited methods.

The most obvious finding would now be the GetClass-method which Class-object provides the metainformation about the type of the respective object. If you would like to have more information here (e.g. the type name in the form of a string), the next step would be a look into the Class– Class. For example, one finds a method getTypeName.

Seliba
10 months ago

This goes with the documentation of Java or the libraries, the so-called Javadocs. Javadocs for Java 21 for example here. The search is your best friend. Often the information from the Javadocs is displayed directly in the IDE (IntelliJ IDEA, Eclipse, Visual Studio Code) if you use it.

However, Javadocs usually only tell you what classes there are and what methods and methods there are and how all are connected. When you use something, you have to find out yourself.

orochi02
10 months ago

google.

How?

you need xy so you googles how to put it in java

Example:

you want to convert a list into a set so googlest you:

java list to set.

what do you get? stackoverflow answer. the solution for the example would look like this:

Set.copyOf(list);

repeat this a few times and you will eventually remember where you will find the most important features for what you want to achieve

orochi02
9 months ago
Reply to  MrPotatoman

ah the part I have read, I thought it was about the question in general. but in the round, this is probably a certain basic knowledge and pray that your prof will list functions to be used accordingly. but on the basis of your basic knowledge you can pierce in the IDE with STRG + LEERTASTE