Test1.java(java homework)
public class Test1 {
public static void main(String[] args) {
//assignment
byte bval1 = 1, bval2 = 2;
short sval1 = 1, sval2 = 2;
int ival1 = 1, ival2 = 2;
long lval1 = 1, lval2 = 2;
float fval1 = 1.0f, fval2 = 2.0f;
double dval1 = 1.0, dval2 = 2.0;
char cval1 = 'a', cval2 = 'b';
boolean flag1 = false, flag2 = true;
//cast
lval1 = ival1;
dval1 = fval1;
fval1 =(float) dval1;
cval1 =(char) bval1;
}
}
相关文档:
首先在公共类写好数据库连接和关闭方法:
public static Connection getConnection(){
Connection conn = null;
try {
Context ic = new InitialContext();
DataSource source = (DataSource)ic.lookup("java:comp/env/jdbc/ownHome");
conn = source.getConnection();
} catch (NamingExcepti ......
1.java调用cmd命令:
Runtime.getRuntime().exec("taskkill /f /im firefox.exe");
2.使用了loadProp()方法调用jar包内的properties文件
使用java程序监控geneFTP服务器(使用windows计划任务执行jar包),代码如下:(工程目录结构见附件)
Task.java:
package com.monitor;
import java.io.BufferedReader;
import java ......
import java.net.url;
import java.sql.*;
public class javaoracle {
public javaoracle() {
}
public static void main(string[] args){
try
{
try{
class.forname("oracle.jdbc.driver.oracledriver");
}
catch(java.lang.classnotfoundexception e)
{
system.err.print(e.getmessage());
} ......
编译eclair碰到java version "1.5.0_18"问题的解决
make提示:
Your version is: java version "1.5.0_18"
修改
build\core\main.mk
# Check for the correct version of java
java_version := $(shell java -version 2>&1 | head -n 1 | grep '[ "]1\.6[\. "$$]')
改成:
java_version := $(shell java -ve ......
经过长时间的面试,以下是JAVA面试的常见的笔试题的整理。
1、String和StringBuffer的区别
JAVA平台提供了两个类:String和StringBuffer,它们可以储存和操纵字符串,即包含多个字符的字符数据。
String类提供了数值不可变的字符串。StringBuffer类提供的字符串进行修改。当知道字符数据要改变 ......