JAVA常用类的使用方法
JAVA常用类的使用方法
1、Integer类
2、Float类
3、Double类
4、Character类
5、String类
6、StringTokenizer类
7、StringBuffer类
8、Random类
1.Integer类的使用方法
Interger:整数类型
1、属性。
static int MAX_VALUE:返回最大的整型数;
static int MIN_VALUE:返回最小的整型数;
static Class TYPE :返回当前类型。
例子:
System.out.println("Integer.MAX_VALUE: " + Integer.MAX_VALUE );
结果为:Integer.MAX_VALUE: 2147483647
2、构造函数。
Integer(int value) :通过一个int的类型构造对象;
Integer(String s) :通过一个String的类型构造对象;
例子:
Integer i = new Integer("1234");
生成了一个值为1234的Integer对象。
3、方法。
说明:
1. 所有方法均为public;
2. 书写格式:[修饰符] <返回类型> <方法名([参数列表])>
如:
static int parseInt(String s) 表示:此方法(parseInt)为类方法(static),返回类型为(int),方法所需参数为String类型。
1. byteValue():取得用byte类型表示的整数;
2. int compareTo(Integer anotherInteger) :比较两个整数。相等时返回0;小于时返回负数;大于时返回正数。
例子:
Integer i = new Integer(1234);
System.out.println("i.compareTo: " + i.compareTo(new Integer(123)) );
结果为:i.compareTo: 1
3. int compareTo(Object o) :将该整数与其他类进行比较。如果o也为Integer类,进行方法2 的操作;否则,抛出ClassCastException异常。
4. static Integer decode(String nm) :将字符串转换为整数。
5. double doubleValue() :取得该整数的双精度表示。
6. boolean equals(Object obj) :比较两个对象。
7. float floatValue() :取得该整数的浮点数表示。
8. static Integer getInteger(String nm) :根据指定名确定系统特征值。
9. static Integer getInteger(String nm, int val) :上面的重载。
10. static Integer getInteger(String nm, Integer val) :上面的重载。
11. int hashCode() :返回该整数类型的哈希表码。
12. int intValue() : 返回该整型数所表示的整数。
13. long longValue() :返回该整型数所表示的长整数。
14. static int parseInt(String s) :将字符串转换成整数。s必须是时进制数组成,否则抛出NumberFormatException异常。
15. static int parseInt(S
相关文档:
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--每页显示记录条数
@currentpage int output,--第几页
@orderid nvarchar(50),--主键排序
@sort int,--排序方式,1表示升序,0表示降序排列
......
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import com.paic.is.dispatch.TMPEntry;
public class FileUtil
{
public static File getFileByRelativePath(String ......
/**
* 把指定的内容写到指定路径的文本文件上
*
* @param path指定路径
* @param context 要写的内容
*/
public static void writeFile(String path, String context) {
// 从控制台输入内容写入文件
try {
FileWriter fw = new FileWriter(path, true);
PrintWriter pw = new Print ......
import java.io.*;
class BigInt
{
int a[];
int len;
BigInt(String str)
{
{
len=str.length();
a=new int[len];
for(int i=0;i<len;i++)
{
this.a[i]=str.charAt(i)-48;
}
&nb ......
Java 是一门支持多线程的的语言,但在处理多线程事件时我们必须注意这样一个问题:多个线程可能同时对同一对象的修改。如果我们不及时作出处理,可能引起对象值的混乱。其实处理办法也很简单,就是当一个线程处理一个对象,锁住该对象。 ......