赞
踩
Scanner sc = new Scanner(System.in);
String input = sc.nextLine();
System.out.println(input);
Stack stack = new Stack<>(); System.out.println(stack.empty()); System.out.println(stack.size()); stack.push(1); stack.push(2); stack.push(3); stack.push(4); System.out.println(stack.empty()); System.out.println(stack.size()); //peek查看栈顶元素不用删除 pop弹出栈顶元素 System.out.println(stack.peek()); System.out.println(stack.pop()); System.out.println(stack.pop()); System.out.println(stack.pop()); System.out.println(stack.pop()); System.out.println(stack.empty());
Queue queue = new LinkedList();
queue.offer(1);//入队列
queue.offer(2);//入队列
queue.offer(3);//入队列
System.out.println(queue.isEmpty());
System.out.println(queue.peek());//获取队头元素,但是不出队列
System.out.println(queue.poll());//出队列
System.out.println(queue.poll());//出队列
System.out.println(queue.poll());//出队列
Deque deque = new LinkedList<>();
deque.isEmpty();//判断空
deque.peekFirst();//访问队头数据
deque.peekLast();//访问队尾数据
deque.addFirst(2);
deque.addLast(1);//在队尾插入数据
deque.removeLast();//移除队尾数据
deque.removeFirst();//移除队头数据
队列中的元素会排序,是通过堆排序实现的
注意:优先级队列插入的元素不能为空
Collections.reverse(List<?> list)
Arrays.sort(array)
Arrays.sort(array,comparator)
Collections.sort(list)
Collections.sort(list,comparator)
Arrays.fill()函数
Collections.fill()函数
String str = "are you ok ?";
String[] strings = str.split(" ");
for (int i = 0; i < strings.length; i++) {
System.out.println(strings[i]);
}
String str = "are you ok ?";
int index1 = str.indexOf('r');
System.out.println(index1);
int index2 = str.indexOf("you");
System.out.println(index2);
String str = "Are you ok ?";
String upperStr = str.toUpperCase();
String lowerStr = str.toLowerCase();
System.out.println(upperStr);
System.out.println(lowerStr);
substring
Math.MAX_VALUE
Math.MIN_VALUE
Math.sqrt(x)
Math.pow(x,2)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。