How to use common APIs in java?

Table of contents

API (Application Programming Interface) overview

How to use the API?

API(Application Programming Interface)概述

        –Application Programming Interface

        –Write a robot program to control the robot to play football. The program needs to issue various commands to the robot such as running forward, running backward, shooting, grabbing the ball, etc. There is no programming It is difficult for people who have experienced programming to imagine how to write such a program. But for experienced developers, they know that robot manufacturers will definitely provide some Java classes for controlling robots, and operations are defined in these classes. Various actions of the robot. In fact, theseJava classes are the interfaces provided by robot manufacturers for application programming. We call these classesAPI . The Java API involved in this chapter refers to the various types of services provided in JDK FunctionalJava classes.

How to useAPI?

  • Open help document
  • Click Show, find the index, and see the input box
  • Who do you want?

        –Enter in the input box and press Enter

  • Look at the bag

        –java.lang classes do not need to import packages, others do

  • See explanations and descriptions of classes
  • Learn how to construct
  • Use member methods

I am using:JDK API 1.6 CHM. If you need API documentation, please send me a private message

Take the random class as an example to see how to check the API

 Taking the Scanner class as an example, enter a string

 

package com.demo01;

import java.util.Scanner;

/*
 * Scanner:用于获取键盘数据(基本数据类型,字符串类型)
 * 		public String nextLine():获取键盘录入的字符串数据
 */
public class ScannerDemo {
	public static void main(String[] args) {
		//创建一个新的对象
		Scanner sc = new Scanner(System.in);
		
		//接收数据,输入一个字符串,方法为:nextLine
		System.out.println("请输入一个字符串数据");
		String s = sc.nextLine();
		
		//输出及结果
		System.out.println("s:"+s);
	}
}

 

Guess you like

Origin blog.csdn.net/zywcxz/article/details/128776132