| English | 意味 |
|---|---|
| library/ˈlaɪbrəri/ | ライブラリ |
| API/ˌeɪ piː ˈaɪ/ | API |
Standing on others' code
- You don't write everything from scratch — Java ships with huge amounts of ready-made code.
- A library 库 is a collection of pre-written classes you can use.
- Java's standard library includes
String,Math,Scanner,ArrayList, and thousands more. - Reusing tested library code is faster and safer than reinventing it.
What an API tells you
- An API (Application Program Interface) 应用程序接口 is the documented list of what a class offers.
- It tells you each method's name, what parameters it takes, and what it returns.
- You program to the API — you use a method by its documented behavior, not its inner code.
- The API is a contract: "give me these inputs, I'll give you this output."

A library groups classes; each class documents the methods you can call
Importing a class
- Some classes need an
importstatement before you use them. import java.util.Scanner;makesScanneravailable.- Core classes like
StringandMathare injava.lang— imported automatically. - The import goes at the top of the file, above the class.
Use it without seeing inside
- You can call
Math.sqrt(x)without knowing how it computes a square root. - This is abstraction: the API hides the implementation behind a simple interface.
- You only need the what (the documented behavior), not the how.
- Good libraries let you build fast by treating complex code as a black box.
ライブラリを使うか、自身で書くか?
標準ライブラリが既に処理を行うかどうかで、各タスクを分類せよ。
You program to the API's documented behavior, not its internal code. Read what a method takes and returns — you don't need (or want) to see how it works inside. Remember most classes need an import, but java.lang classes (String, Math, System, Integer) are imported automatically, so Scanner needs import java.util.Scanner; while Math does not.
Using the Math library:
- No import needed —
Mathis injava.lang. double r = Math.sqrt(16);→ris4.0, and you never see the algorithm.- The API just promised: "give me a number, I return its square root."
A library is reusable pre-written code; the API documents each class's methods — their names, parameters, and return values — so you program to the documented behavior. Most classes need an import (e.g. Scanner), but java.lang classes (String, Math) are imported automatically. The API is abstraction: use it without seeing inside.
APIはクラスのメソッドをドキュメント化し、それらの...について説明する
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
内側のコードではなく、ドキュメントされた名前/パラメータ/返り値に対してプログラムを書く。
使用前にimport文が必要なのはどのクラスか?
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
java.langのクラスは自動でインポートされ、Scanner (java.util)にはimportが必要である。
ライブラリメソッドの内部コードを読む前に使用することはできない。
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
ドキュメントされた振る舞いによって使用する — これが抽象化である。
事前に書かれており再利用可能なクラスの集まりを ___ (単語一つ)と呼ぶ。
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
ライブラリは再利用可能なコードを束ねている。
MathとStringは自動でインポートされるのは、java.langに含まれているからである。
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
java.langはすべてのJavaプログラムでデフォルトでインポートされている。