JAVA CODE

字节

1TB = 1024GB                 byte   1字节
1GB = 1024MB                short   2字节  char
1MB = 1024KB                  int   4字节
1KB = 1024Byte               long   8字节
1Byte = 8bit

hile(-1 != (pos = str1.indexOf("Day",pos)))
if(.. instanceof ..)          强转之前做判断 父 = new; if(instanceof)
"bye".equals(str)             字符串是否相等
printf                        打印16进制 %x %X
getInstance()                 仅一个对象

Thread.sleep(1000);           表示模拟睡眠1秒的效果 //需要 throws Exception

Random ran = new Random();    ran.nextInt(100); 0~99随机数

Math.pow(a,b)                 a底数 b指数
Math.sqrt(a)                  平方根

int[] arr = new int[5]
int[] arr = [1,2,3,4,5]

Integer.parseInt()            String -> int

Arrays

Arrays.toString(arr) 			数组打印
Arrays.fill(arr2,10); 			every elements filled with 10
Arrays.equals(arr2,arr3) 		内容和次序相同
Arrays.sort(arr) 				排序
Arrays.binarySearch(arr,59) 	59的index

Arrays.asList(集合)				数组 -> 集合

时间

Calender

java.util.Calender

static Calendar getInstance()
void set(int year, int month, int date, int hourOfDay, int minute, int second)
Date getTime()
void set(int field, int value)
void add(int field, int amount)

Date

java.util.Date

Date()
Date(long date)
long getTIme()
void setTime(long time)

DateTimFormatter

java.time.format.DateTimeFormatter

static DateTimeFormatter ofPattern(String pattern)
String                   format(TemporalAccessor temporal)
TemporalAccessor         parse(CharSequence text)

Instant

java.time.Instant

static Instant now()
OffsetDateTime atOffset(ZoneOffset offset)
static Instant ofEpochMilli(long epochMilli)
long           toEpochMilli()

LocalDateTime

java.time.LocalDateTime

static LocalDateTime now()
static LocalDateTime of(int year, int month, int dayOfMonth, int hour, int minute, int second)
int           getYear()                            获取
int           getMonthValue()                      获取
int           getDayOfMonth()                      获取
int           getHour()                            获取
int           getMinute()                          获取
int           getSecond()                          获取
LocalDateTime withYear(int year)                   设置
LocalDateTIme withMonth(int month)                 设置
LocalDateTIme withDayOfMonth(int dayOfMonth)       设置
LocalDateTime withHour(int hour)                   设置
LocalDateTime withMinute(int minute)               设置
LocalDateTime withSecond(int second)               设置
LocalDateTIme plusYears(long years)                加上
LocalDateTIme plusMonths(long months)              加上
LocalDateTIme plusDays(long days)                  加上
LocalDateTime plusHours(long hours)                加上
LocalDateTIme plusMinutes(long minutes)            加上
LocalDateTime plusSeonds(long seconds)             加上
LocalDateTIme minusYears(long years)               减去
LocalDateTime minusMonths(long months)             减去
LocalDateTime minusDays(long days)                 减去
LocalDateTime minusHours(long hours)               减去
LocalDateTime minusMinutes(long minutes)           减去
LocalDateTime minusSeconds(long seconds)           减去

LocalTime

java.time.LocalTime

static LocalTime now()
static LocalTime now(ZoneId zone)

LocalDate

java.time.LocalDate

static LocalDate now()

SimpleDateFormat

java.text.SimpleDateFormat

SimpleDateFormat()
SimpleDateFormat(String pattern)        y-年 M-月 d-日 H-时 m-分 s-秒
final String format(Date date)
Date parse(String source)

集合

Collection

java.util.Collection

boolean add(E e); 							对象
boolean addAll(Collection<? extends E>c)  	对象中元素
boolean contains(Object o); 				对象
boolean containsAll(Collection<?> c) 		对象中元素
boolean retainAll(Collection<?> c) 			比较
boolean remove(Object o);					对象
boolean removeAll(Collection<?> c)	 		对象中元素
void    clear(); 	
int     size();	 
boolean isEmpty();	 
boolean equals(Object o) 
int     hashCode()	 						
Object[] toArray() 							集合 -> 数组
Iterator iterator()							迭代器

Collections

java.util.Collections

static <T extends Object & Comparable<? super T>> T max(Collection<? extends T> coll)	 
static T 											max(Collection<? extends T> coll, Comparator<? super T> comp)	 
static <T extends Object & Comparable<?super T>> T  min(Collection<? extends T> coll)	 
static T 											min(Collection<? extends T> coll, Comparator<? super T> comp) 
static void 										copy(List<? super T> dest, List<? extends T> src)
static void 									reverse(List<?> list) 
static void 									shuffle(List<?> list)	 
static <T extends Comparable<? super T>> void 	sort(List list)	 
static void 									sort(List list, Comparator<? super T> c)	 
static void 									swap(List<?> list, int i, int j)

Iterator

java.util.Iterator

boolean hasNext()
E       next()
void    remove()

List

java.util.List

void 	add(int index, E element)	 
boolean addAll(int index, Collection<? extends E> c) 
E 		get(int index) 
int 	indexOf(Object o) 
int 	lastIndexOf(Object o)	 
E 		set(int index, E element)	 
E 		remove(int index)	 	
List 	subList(int fromIndex, int toIndex)

Queue

java.util.Queue

boolean offer(E e) 		添加
E       poll()	 		删除
E       peek()

Map<K,V>

java.util.Map<K,V>

V 					put(K key, V value)				增加,修改
V 					get(Object key)boolean 			containsKey(Object key);		查key
boolean 			containsValue(Object value);	查value
V 					remove(Object key)				删除
Set	 				keySet()						key集合视图
Collection 			values()						value集合视图
Set<Map.Entry<K,V>> entrySet()						映射(key=vlaue 对)

Math

java.lang.Math

static int 		max(int a, int b) 
static int 		min(int a, int b) 
static double 	pow(double a, double b) 
static int 		abs(int a)	 
static long 	round(double a)	 
static double 	sqrt(double a) 
static double 	random()

字符

StringBuilder

StringBuilder()                    16
StringBuilder(int capacity)        
StringBuilder(String str)  
int capacity()                     容量
int length()                       长度
StringBuilder insert(int offset, String str)
StringBuilder append(String str)
StringBuilder deleteCharAt(int index)
StringBuilder delete(int start, int end)
StringBuilder replace(int start, int end, String str)
StringBuilder reverse()
char       charAt(int index)                         字符
int        index(int ch)                             index
int        indexOf(int ch, int fromIndex)            index
int        indexOf(String str)                       index
int        indexOf(String str, int fromIndex)        index
int        indexOf(String str, int fromIndex)        index
int        lastIndexOf(int ch, int fromIndex)        index
int        lastIndexOf(String str)                   index
int        lastIndexOf(String str, int fromIndex)    index
String     replace(char oldChar, char newChar)       正则表达式 替换
String     replace(String regex, String replacement)
String     substring(int beginIndex)                 subString
String     substring(int beginIndex, int endIndex)   subString

String

String()
String(byte[] , int offset, int length)
String(byte[] )
String(char[] , int offset, int count)
String(char[])
String 	   toString()
byte[]     getBytes()                                转换为数组
char[]     toCharArray()                             转换为数组
char       charAt(int index)                         字符
int        length()                                  长度
boolean    isEmpty()                                 是否空
int        compareTo(String anotherString)           比较
int        compareToIgnoreCase(String str)           比较
boolean    contains(CharSequence s)                  包含
String     toLowerCase()                             小写
String     toUpperCase()                             大写
String     trim()                                    前后空格 X
boolean    startsWith(String prefix)                 starts
boolean    startsWith(String prefix, int offset)     starts
boolean    endsWith(String suffix)                   ends
boolean    equals(Object anObject)                   equals
boolean    equalsIgnoreCase(String anotherString)    equals
int        index(int ch)                             index
int        indexOf(int ch, int fromIndex)            index
int        indexOf(String str)                       index
int        indexOf(String str, int fromIndex)        index
int        indexOf(String str, int fromIndex)        index
int        lastIndexOf(int ch, int fromIndex)        index
int        lastIndexOf(String str)                   index
int        lastIndexOf(String str, int fromIndex)    index
String     substring(int beginIndex, int endIndex)   subString
String     substring(int beginIndex)             subString
boolean    matches(String reges)                 正则表达式
String[]   split(String regex)                   正则表达式 切字符串
String     replace(char oldChar, char newChar)   正则表达式 替换
String     replace(String regex, String replacement)

System

static long currentTimeMillis()            19701100秒 毫秒

System.arraycopy(arr, 1, brr, 0, 3)        数组拷贝
System.out.prinln()                        输出
System.in                                  输入

Scanner

Scanner import java.util.Scanner;
Scanner myObj = new Scanner(System.in);
myObj.nextline();
myObj.nextInt();
myObj.nextBoolean()
myObj.nextByte()
myObj.nextDouble()
myObj.nextFloat()
myObj.nextInt()
myObj.nextLine()
myObj.nextLong()
myObj.nextShort()

ERROR

Exception in thread "main" java.lang.
ArithmeticException                算术异常
Arrayindexoutofboundsexception     数组下标边越界异常
StringIndexOutOfBoundsException    字符串下标业界异常
NullPointerException               空指针异常
ClassCastException                 类型转换异常
NumberFormatException              数字格式异常
IllegalArgumentException           非法参数异常

快捷键

ctrl + D                 复制当前行
art + shift + 方向        移动代码
ctrl + /                 当行注释 再来一次取消
ctrl + shift + /         多行注释 再来一次取消
alt + Enter              可是实现返回值的生成

ctrl + 点击               查看原码
ctrl + n                 搜索并打开类的源码
ctrl + F12 				 搜索类中的方法
ctrl + alt + <           回到刚刚位置
ctrl + alt + t 			 surround with 

psvm                     public static void mian
main                     public static void mian
sout                     System.out.println();
Impl                     表示接口

@

@              注解、标注
@Override      父类方法的重写,没有构成重写编译报错
@interface     注解关键字 (class

关键字

package         包 、目录
import          包的导入

public          本类 ,同一个包中的类 ,子类 ,其他类
protected       本类 ,同一个包中的类 ,子类
无修饰符         本类 ,同一个包中的类
private         本类

final           类不能继承,成员方法不能重写,成员变量不能改变必须初始化
static          静态,类层级
abstract        抽象 (类,成员方法,成员变量)
default         修饰接口中的非抽象方法的关键字
interface       接口关键字 (classenum            枚举关键字 (classextends         继承类
implements      实现接口 (extends)

null            表示 空,没有对象
""              表示 空字符串对象,有对象,没有内容
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值