I Live Templates Setting
in
if (Objects.isNull($VAR$)) {
return null;
}$END$
nn
if (Objects.nonNull($VAR$)) {
$END$;
}
an
if (ObjectUtils.anyNull($VAR$, $VAR1$)) {
return null;
}$END$
ib
if (StringUtils.isBlank($VAR$)) {
return null;
}$END$
inb
if (StringUtils.isNotBlank($VAR$)) {
$END$;
}
cie
if (CollectionUtils.isEmpty($VAR$)) {
return Collections.emptyList();
}$END$
cine
if (CollectionUtils.isNotEmpty($VAR$)) {
$END$;
}
bfr
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
String str = bf.readLine();
int num = Integer.parseInt(bf.readLine());
bf.close();
sb
StringBuilder sb = new StringBuilder();
循环
fori
for (int i = 0; i < ; i++) {
}
.fori
.forr
itar
for (int i = 0; i < args.length; i++) {
String arg = args[i];
}
ritar
for (int i = args.length - 1; i >= 0; i--) {
String arg = args[i];
}
itli
for (int i = 0; i < dishes.size(); i++) {
Dish dish = dishes.get(i);
dishes 为最近的变量
}
I
for (Object o :) {
}
iter
for (Dish dish : dishes) {
dishes 为最近的变量
}
.iter / .for Iterates over an enumerable collection.
itco
for (Iterator<Dish> iterator = dishes.iterator(); iterator.hasNext(); ) {
Dish next = iterator.next();
dishes 为最近的变量
}
itit
while (iterator.hasNext()) {
Object next = iterator.next();
}
iten
while (enumeration.hasMoreElements()) {
Object nextElement = enumeration.nextElement();
}
.while
public class Foo {
void m(boolean x) {
x.while
return;
}
}
public class Foo {
void m(boolean x) {
while (x) {
}
return;
}
}
修饰符等关键字
prsf
private static final
psf
public static final
psfi
public static final int
psfs
public static final String
St
String
thr
throw new
.par Parenthesizes an expression.
输出相关
serr
System.err.println();
.serr
serrc
System.err::println
souf
System.out.printf("");
.souf
sout
System.out.println();
.sout
soutc
System.out::println
soutm
System.out.println("Test.main");
soutp
System.out.println("args = " + Arrays.deepToString(args));
soutv
System.out.println("dishes = " + dishes);
soutv
数学相关
mn
= Math.min(, );
mx
= Math.max(, );
锁相关
RL
.readLock().lock();
try {
} finally {
.readLock().unlock();
}
WL
.writeLock().lock();
try {
} finally {
.writeLock().unlock();
}
线程相关
C
Callable<Object> callable = new Callable<Object>() {
public Object call() throws Exception {
}
};
.synchronized
null 等条件判断相关
ifn
if (dishes == null) {
dishes 为最近的变量
}
.null Checks that an expression is null.
inn
if (dishes != null) {
dishes 为最近的变量
}
.nn / .notnull Checks that an expression is not null.
lazy
if (dishes == null) {
dishes = new List<Dish>();
}
! / .not Negates a boolean expression.
.if Checks that a boolean expression is true.
.else Checks that a boolean expression is false.
集合数组转换
toar
dishes.toArray(new Object[0])
lst
args[args.length - 1]
StringTokenizer
ittok
for (StringTokenizer stringTokenizer = new StringTokenizer(); stringTokenizer.hasMoreTokens(); ) {
String s = stringTokenizer.nextToken();
}
Java多态
inst
if (dishes instanceof Object) {
Object o = (Object)dishes;
dishes 为最近的变量
}
.castvar Creates a new variable for the expression with type casting.
.inst / .instanceof Surrounds an expression with instanceof.
.cast Surrounds an expression with a cast.
方法相关
main
public static void main (String[]args){
}
psvm
public static void main (String[]args){
}
geti
public static Test getInstance () {
return getInstance;
}
.new Inserts a new call for a class.
.arg Wraps an object with a function call.
.field Introduces a field for an expression. (有问题)
实际会这样
.return
.switch
toCompletable (IDEA 显示有问题)
toFlowable
.toFlux
.toMaybe
.toMono
.toObservable
.toSingle
String 方法相关
.format Creates a String.format call.
.val
.varl
.var
异常
.throw
.try
.twr
public class Foo {
void m() {
getStream().twr
}
AutoCloseable getStream()
{
return null;
}
}
public class Foo {
void m() {
try (AutoCloseable stream = getStream()) {
} catch (Exception e) {
}
}
AutoCloseable getStream()
{
return null;
}
}
测试相关
.assert Creates an assertion from a boolean expression.
.test / .testN
java8
.lambda Surrounds an expression with a lambda.
.opt Creates an Optional object.
.reqnonnull Wraps an object with Objects.requireNonNull.
.stream