仅作为自己做算法的小笔记
目录
1. 2019-10-25:String和int之间的相互转化:
1. 2019-10-25:String和int之间的相互转化:
//string转换成int :
Integer.valueOf("12")
//int转换成string :
String.valueOf(12)
参考博客:java中的字符,字符串,数字之间的转换
2.java的栈Stack<E>
方法摘要(来自API1.6.0)
boolean | empty() 测试堆栈是否为空。 |
E | peek() 查看堆栈顶部的对象,但不从堆栈中移除它。 |
E | pop() 移除堆栈顶部的对象,并作为此函数的值返回该对象。 |
E | push(E item) 把项压入堆栈顶部。 |
int | search(Object o) 返回对象在堆栈中的位置,以 1 为基数。 |
3.String(字符串)截取某个char
(来自API1.6.0)
char | charAt(int index) 返回指定索引处的 char 值。 |
4. char的封装类是Character
5. Java提供的数据格式化类DecimalFormat的format方法
示例:
public static void main(String[] args) {
int a = new Scanner(System.in).nextInt();
String b = new DecimalFormat("#.0000000").format(Math.PI*a*a);
System.out.println(b);
}