cd /usr/lib/jvm/java
-1.5.0-sun-1.5.0.15/jre/lib/fonts
sudo mkdir fallback
cd fallback
sudo cp /usr/share/fonts/truetype/arphic/uming.ttc /usr/lib/jvm/java
-1.5.0-sun-1.5.0.15/jre/lib/fonts/fallback
sudo mkfontdir
sudo mkfontscale ......
1、String是最基本的数据类型吗?
基本数据类型包括byte、int、char、long、float、double、boolean和short。
java.lang.String类是final类型的,因此不可以继承这个类、不能修改这个类。为了提高效率节省空间,我们应该用StringBuffer类
2、int 和 Integer 有什么区别
Java 提供两种不同的类型:引用类型和原始类型(或内置类型)。Int是java的原始数据类型,Integer是java为int提供的封装类。Java为每个原始类型提供了封装类。
原始类型封装类
booleanBoolean
charCharacter
byteByte
shortShort
intInteger
longLong
floatFloat
doubleDouble
引用类型和原始类型的行为完全不同,并且它们具有不同的语义。引用类型和原始类型具有不同的特征和用法,它们包括:大小和速度问题,这种类型以哪种类型的数据结构存储,当引用类型和原始类型用作某个类的实例数据时所指定的缺省值。对象引用实例变量的缺省值为 null,而原始类型实例变量的缺省值与它们的类型有关。
3、String 和StringBuffer的区别
JAVA平台提供了两个类:String和StringBuffer,它们可以储存和操作字符串,即包含多个字符的字符数据。这个String类提供了数值不可改变的字符串。而这个StringBuf ......
System.currentTimeMillis():可以提取到当前时间的毫秒数,产生一个当前的毫秒,这个毫秒其实就是自1970年1月1日0时起的毫秒数。
常见作用:一般都是用2个时间的差值来得到运行时间的,常用来比较2个算法的效率!
long start = System.currentTimeMillis();
// 这里可以加上你要知道的方法运行的时间!!
long end = System.currentTimeMillis();
System.out.println("运行时间:"+(end - start));
格式化System.currentTimeMillis()
1 import java.text.SimpleDateFormat;
2 import java.util.Locale;
3
4
5 public class FormatCurrentTime {
6 /**
7 * @param args
8 */
9 public static void main(String[] args) {
10
11 Sim ......
Linux配置java开发平台
一、安装jdk
1.下载安装jdk
(1)、首先,在http://java.sun.com
找到要下载的jdk,下载自己需要的jdk版本。我这里使用的是jdk6,得到的是一个名为jdk-6u6-linux-i586-rpm.bin的文件。此文件当前为不可运行的shell script。
(2)、更改权限,提取jdk安装文件:
打开终端运行:#chmod a+x jdk-6u6-linux-i586-rpm.bin
# ./ jdk-6u6-linux-i586-rpm.bin
在按提示输入yes后,jdk被解压到./j2sdk1.4.2_04目录下。
(3)、建立java安装路径 :
# mkdir /usr/java
(4)、安装文件
# rpm -ivh jdk-6u6-linux-i586-rpm
安装软件会将JDK自动安装到/usr/java/目录下。
2、配置环境变量
(1)、打开文件:# vi /etc/profile
在文件中加入:
export JAVA_HOME=/usr/java/ jdk1.6.0_06
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
(2) ......
Linux配置java开发平台
一、安装jdk
1.下载安装jdk
(1)、首先,在http://java.sun.com
找到要下载的jdk,下载自己需要的jdk版本。我这里使用的是jdk6,得到的是一个名为jdk-6u6-linux-i586-rpm.bin的文件。此文件当前为不可运行的shell script。
(2)、更改权限,提取jdk安装文件:
打开终端运行:#chmod a+x jdk-6u6-linux-i586-rpm.bin
# ./ jdk-6u6-linux-i586-rpm.bin
在按提示输入yes后,jdk被解压到./j2sdk1.4.2_04目录下。
(3)、建立java安装路径 :
# mkdir /usr/java
(4)、安装文件
# rpm -ivh jdk-6u6-linux-i586-rpm
安装软件会将JDK自动安装到/usr/java/目录下。
2、配置环境变量
(1)、打开文件:# vi /etc/profile
在文件中加入:
export JAVA_HOME=/usr/java/ jdk1.6.0_06
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
(2) ......
Executing a CommandSee also e90 Reading Output from a Command.
try {
// Execute a command without arguments
String command = "ls";
Process child = Runtime.getRuntime().exec(command);
// Execute a command with an argument
command = "ls /tmp";
child = Runtime.getRuntime().exec(command);
} catch (IOException e) {
}
If an argument contain spaces, it is necessary to use the overload that requires the command and its arguments to be supplied in an array:
try {
// Execute a command with an argument that contains a space
String[] commands = new String[]{"grep", "hello world", "/tmp/f.txt"};
commands = new String[]{"grep", "hello world", "c:\\Documents and Settings\\f.txt"};
Process child = Runtime.getRuntime().exec(commands);
} catch (IOException e) {
}
e90. Reading Output from a Commandtry {
// Execute command
String command = "ls";
Process ......
Executing a CommandSee also e90 Reading Output from a Command.
try {
// Execute a command without arguments
String command = "ls";
Process child = Runtime.getRuntime().exec(command);
// Execute a command with an argument
command = "ls /tmp";
child = Runtime.getRuntime().exec(command);
} catch (IOException e) {
}
If an argument contain spaces, it is necessary to use the overload that requires the command and its arguments to be supplied in an array:
try {
// Execute a command with an argument that contains a space
String[] commands = new String[]{"grep", "hello world", "/tmp/f.txt"};
commands = new String[]{"grep", "hello world", "c:\\Documents and Settings\\f.txt"};
Process child = Runtime.getRuntime().exec(commands);
} catch (IOException e) {
}
e90. Reading Output from a Commandtry {
// Execute command
String command = "ls";
Process ......
package com.lovo.cq.shopping10_1.common;
import java.sql.*;
public class DbUtil {
private PreparedStatement pstmt = null;
private Connection con = null;
public DbUtil() {
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost/ShoppingBook10_1",
"root", "root");;
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
}
public Connection getCon() {
return con;
}
public void close() {
if (pstmt != null) {
try {
pstmt.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (con != null) {
try {
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
......
package com.lovo.cq.shopping10_1.common;
import java.sql.*;
public class DbUtil {
private PreparedStatement pstmt = null;
private Connection con = null;
public DbUtil() {
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost/ShoppingBook10_1",
"root", "root");;
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
}
public Connection getCon() {
return con;
}
public void close() {
if (pstmt != null) {
try {
pstmt.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (con != null) {
try {
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
......