API(Scanner、Random、ArrayList、String、Arrays、Math)
Scanner
import java.util.Scanner;
/*
public int nextInt(): to get a integer from keyboard
public String next(): to get a string from keyboard,end with space;
Scanner sc = new Scanner(System.in);
*/
Random
import java.util.Random;
// 构造方法:
// public Random():创建一个新的随机数生成器;
// 成员方法:
// public int nextInt(int bound):产生0~n的随机数,但是不包括n
ArrayList
import java.util.ArrayList
// 构造方法:
// public ArrayList():构造一个内容为空的集合
// 基本格式:
// ArrayList<String> StringList = new ArrayList<>();
// ArrayList<Integer> intList = new ArrayList<>();
// 成员方法:
// public boolean add(E e):在集合中加入元素到尾部
// public E remove(int index):删除指定位置上的元素,并且返回被删除元素;
// public E get(int index):获取指定位置上的元素,并且返回;
// public int size():返回几个元素的个数。
String
import java.lang.String;
// 位于java.lang,不用添加import语句;
// 构造方法:
// public String():构造一个空的字符串;
// public String(char[] chars):以字符数组作为参数,据此构造一个字符串
// public String(byte[] bytes):以字节数组作为参数,据此构造一个字符串
// 成员方法:
// 1.public boolean equals(Object ojb):字符串比较
// 2.public boolean equalsIgoreCase(String anotherString):忽略大小写的比较
// 3.public int length():return the length of the String
// 4.public String concat(String str):将参数字符串连接到该字符串的末尾
// 5.public char charAt(int index):返回指定索引处的char值
// 6.public int indexOf(Strig str):返回参数字符串第一次出现在该字符串的位置,没有出现就返回-1
// 7.public String substring(int beginIndex):从beginIndex开始截取字符串直到结尾
// 8.public String substring(int beginIndex, int endIndex):从beginIndex开始截取字符串直到endIndex,不包括endIndex
// 9.public char[] toCharArray():字符串转化为字符数组
// 10.public byte[] getBytes():字符串转化为字节数组
// 11.public String replace(CharSequence target, CharSequence replacement):将字符串中的target子串全都替换为replacement
// 12.public String[] split(String regex):将字符串按照给定的规则拆分,返回一个字符串数组
Arrays
提供操作数组的方法,都是静态方法
import java.util.Arrays;
1.public static String toString(int[] a):返回一直字符串
int[] a = {1, 2, 3, 4, 5, 6};
String str = Arrays.toString(a);
System.out.println(str);// [1, 2, 3, 4, 5, 6]
2.public static void sort(int[] a):排序
Arrays.sort(a);
Math
import java.lang.Math
public static double Math.abs(double a):
// :返回大于等于参数的最小整数
public static double ceil(double a)
// 返回小于等于参数的最大整数
public static double floor(double a)
// 返回最接近参数的long
public static long round(double)
API(Scanner、Random、ArrayList、String、Arrays、Math)的更多相关文章
- API之Scanner,Random,ArrayList基础运用。重点是ArrayList
有关API的这些类可以参考JDK的官方中文文档,看我的另一篇文章有下载==> https://www.cnblogs.com/gz18221/p/11968505.html<==文章地址 ...
- JAVA基础学习之 Map集合、集合框架工具类Collections,Arrays、可变参数、List和Set集合框架什么时候使用等(4)
package com.itcast.test20140113; import java.util.ArrayList; import java.util.Arrays; import java.ut ...
- Python——常用模块(time/datetime, random, os, shutil, json/pickcle, collections, hashlib/hmac, contextlib)
1.time/datetime 这两个模块是与时间相关的模块,Python中通常用三种方式表示时间: #时间戳(timestamp):表示的是从1970年1月1日00:00:00开始按秒计算的偏移量. ...
- 01 语言基础+高级:1-3 常用API第一部分_day07【Scanner类、Random类、ArrayList类】
day07[Scanner类.Random类.ArrayList类] Scanner类Random类ArrayList类 教学目标 能够明确API的使用步骤能够使用Scanner类获得键盘录入数据能够 ...
- TensorFlow Object Detection API(Windows下测试)
"Speed/accuracy trade-offs for modern convolutional object detectors." Huang J, Rathod V, ...
- Java(114-132)【Scanner类、Random类、ArrayList类】
1.API概述和使用步骤 应用程序编程接口.Java的API是一本程序员的字典,学会查询 2.Scanner 概述及其API文档 键盘输入 类都是大写的Scanner,关键字是小写的public 3. ...
- java自学第4期——:Scanner类、匿名对象介绍、Random类、ArrayList集合、标准类格式、String类、static静态、Arrays工具类、Math类(1)
一.Scanner类 1.api简介: 应用程序编程接口 2.Scanner类: 作用:获取键盘输入的数据 位置: java.util.Scanner. 使用:使用成员方法nextInt() 和 ne ...
- Scanner类、匿名对象、Random类、ArrayList集合、String类、static静态类、math类和Arrays工具类
一.Scanner类 1.除了八种基本数据类型,其他都是引用类型: 引用类型使用三步骤: 2.Scanner类 引用jdk提供的类,Scanner在java.util包下,不在java.lang包(S ...
- Java运算符和引用数据类型(Scanner、Random)
运算符 算术运算符: 运算符 运算规则 范例 结果 + 正号 +3 3 + 加 2+3 5 + 连接字符串 “中”+“国” “中国” - 负号 int a=3;-a -3 - 减 3-1 2 * 乘 ...
随机推荐
- HNOI2019 游记
HNOI2019 游记 Day 0 其实考前几天,心里还是挺慌的.结果最后 Day 0 的时候,因为种种原因反而释然了.也许是觉得,在这一步退役,也没有什么好害怕的吧. OI 本身就是一项偶然性太大的 ...
- 09 Zabbix4.0系统clone、mass update使用
点击返回:自学Zabbix之路 点击返回:自学Zabbix4.0之路 点击返回:自学zabbix集锦 09 Zabbix4.0系统clone.mass update使用 1. clone使用: clo ...
- centos7/rhel7下安装redis4.0集群
相关介绍:Redis从3.0版本开始支持集群! 集群一般由多个节点组成,节点数量至少6个才能保证组成完整高可用的集群. 每个节点需要开启配置文件中的cluster-enabled yes,让Redis ...
- 假如你不小心干掉了系统,你该怎么办?(一次手贱的记录 ~ Ubuntu and Python3.6)
前言 多年未犯低级错误,今天犯了个不大不小的错误,记录下生活点滴吧 今天早上脑海里想了下,如果电脑挂了我要备份哪些东西?然后中午休息的时候就列了一下,没想到晚上就悲剧了... 这个是中午写的: ## ...
- CentOS6.5安装JDK1.8
1.查看Linux自带的JDK是否已安装(如果安装则卸载CentOS已安装的低版本) 安装好的CentOS会自带OpenJdk,用命令 java -version,会有下面的信息: java -ver ...
- 洛谷P3810 陌上花开 CDQ分治(三维偏序)
好,这是一道三维偏序的模板题 当然没那么简单..... 首先谴责洛谷一下:可怜的陌上花开的题面被无情的消灭了: 这么好听的名字#(滑稽) 那么我们看了题面后就发现:这就是一个三维偏序.只不过ans不加 ...
- A1142. Maximal Clique
A clique is a subset of vertices of an undirected graph such that every two distinct vertices in the ...
- A1109. Group Photo
Formation is very important when taking a group photo. Given the rules of forming K rows with N peop ...
- 【洛谷P1082】同余方程
题目大意:求关于 \(x\) 的同余方程 \[ax \equiv 1 \pmod {b}\] 的最小正整数解. 题解:exgcd 板子题. 代码如下 #include <bits/stdc++. ...
- 封装一个基于NLog+NLog.Mongo的日志记录工具类LogUtil,nloglogutil
封装一个基于NLog+NLog.Mongo的日志记录工具类LogUtil,代码比较简单,主要是把MongoTarget的配置.FileTarget的配置集成到类中,同时利用缓存依赖来判断是否需要重新创 ...