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 * 乘 ...
随机推荐
- dll 修复....
之前在安装时总是会碰到缺少什么dll文件,总是头疼的要命,这次很幸运的在网上搜到了这个神奇的小玩意,只需要运行就能够修复缺少的所有的dll文件,所以在这小小的分享一下. 链接:https://pan. ...
- 【BZOJ2823】[AHOI2012]信号塔(最小圆覆盖)
[BZOJ2823][AHOI2012]信号塔(最小圆覆盖) 题面 BZOJ 洛谷 相同的题: BZOJ1 BZOJ2 洛谷 题解 模板题... #include<iostream> #i ...
- [CF977F]Consecutive Subsequence
题目描述 You are given an integer array of length n. You have to choose some subsequence of this array o ...
- Nginx优化文件编写
server_tokens off; #并不会让nginx执行的速度更快,关闭它可隐藏错误页面中的nginx版本号charset utf-8,gbk; #字符#sendfile on;#tcp_nop ...
- Think Python 2E中译本 _site
http://codingpy.com/books/thinkpython2/index.html
- [POI2005]DWU-Double-row
有2n个士兵站成两排,他们需要被重新排列,以保证每一排里没有同样高的士兵——这样我们就说,士兵们被合理地安排了位置. 每次操作可以交换两个在同一位置(但不在同一排)的士兵.你的任务是用最少的操作来确保 ...
- zabbix3.2添加web页面监控(Web monitoring)
应用场景: 存在一种情况:nginx或者httpd服务本身运行正常,但是网页挂了,类似于网页被黑,或者40X之类的... 可以用zabbix把web页面访问也监控起来,第一时间得知web崩溃信息并做相 ...
- 安装Ubuntu Server18.04(附与CentOS占用体积和Python版本的对比)
这边只演示一下最新系统的安装过程,设置之类的和以前讲的Kali以及CentOS大同小异:https://www.cnblogs.com/dunitian/p/4822808.html#linux 和C ...
- 关于overflow-x: hidden隐藏滚动条失效的解决方案
在苦逼写页面的时候,发现有种情况overflow-x: hidden失效了,chrome表现完好,qq浏览器有问题,微信上面展示有问题. 微信上面展示是一样能够滑动的. 如果出现类似问题的同学,请试一 ...
- POJ--3614 Sunscreen(贪心)
题目 3614 Sunscreen 2500*2500直接排序暴力贪心 #include<iostream> #include<cstring> #include<alg ...