測試代碼 :
在網(wǎng)站設計制作、網(wǎng)站設計中從網(wǎng)站色彩、結(jié)構(gòu)布局、欄目設置、關鍵詞群組等細微處著手,突出企業(yè)的產(chǎn)品/服務/品牌,幫助企業(yè)鎖定精準用戶,提高在線咨詢和轉(zhuǎn)化,使成都網(wǎng)站營銷成為有效果、有回報的無錫營銷推廣。創(chuàng)新互聯(lián)專業(yè)成都網(wǎng)站建設10多年了,客戶滿意度97.8%,歡迎成都創(chuàng)新互聯(lián)客戶聯(lián)系。
import java.util.regex.*;
class Test {
public static void main(String args[]) {
Pattern p;
Matcher m;
String patternString = "\\dA\\d"; // 給出一個正則表達式
String matchedString = "0A1A2A3A4A5A6A7A8A9"; // 給出待匹配的字符序列
p = Pattern.compile(patternString); // 用模式patternString初試化模式對象p
m = p.matcher(matchedString); // 用matchedString初始化匹配對象m
while (m.find()) {
String str = m.group();
System.out.print("從" + m.start() + "到" + m.end() + "匹配模式子序列:");
System.out.println(str); // 查找matchedString中和patternString匹配的全部子字符串,并輸出
// 這些子字符串,以及它們在matchedString中的起止位置
}
String temp = m.replaceAll("####");
System.out.println(temp);
System.out.println(matchedString);
matchedString = ("9A00A3"); // 重新給出待匹配的字符序列
m = p.matcher("9A00A3"); // 重新初始化匹配對象m
if (m.matches()) { // 判斷matchedString是否匹配patternString的條件表達式
String str2 = m.group();
System.out.println(str2);
} else
System.out.println("不完全匹配");
if (m.lookingAt()) // 判斷從matchedString的開始位置是否有和patternString匹配的子序列
{
String str3 = m.group();
System.out.println(str3);
}
}
}
運行結(jié)果:
從0到3匹配模式子序列:0A1
從4到7匹配模式子序列:2A3
從8到11匹配模式子序列:4A5
從12到15匹配模式子序列:6A7
從16到19匹配模式子序列:8A9
####A####A####A####A####
0A1A2A3A4A5A6A7A8A9
不完全匹配
9A0
public?void?add(int?a,int?b){
System.out.println(a+"+"+b+"="+(a+b));
}
public?void?show(){
System.out.println("show方法執(zhí)行了!");
}
package xinguan;
abstract class Operation{ //抽象類
public static double numberA= 0;
public static double numberB = 0;
abstract double getResult(); //抽象方法
}
class OperationADD extends Operation{
@Override
double getResult() {
return numberA+numberB;
}
}
class OperationSUB extends Operation{
@Override
double getResult() {
return numberA-numberB;
}
}
class OperationMUL extends Operation{
@Override
double getResult() {
return numberA*numberB;
}
}
class OperationDIV extends Operation{
@Override
double getResult() {
return numberA/numberB;
}
}
class OperationFactory{
public static Operation createOperate(char operate){
Operation oper = null;
switch (operate){
case'+':
oper= new OperationADD();
break;
case'-':
oper= new OperationSUB();
break;
case'*':
oper= new OperationMUL();
break;
case'/':
oper= new OperationDIV();
break;
}
return oper;
}
}
public class CalculateDemo {
/**
* @param args
*/
public static void main(String[] args) {
Operation operADD = OperationFactory.createOperate('+');
Operation operSUB = OperationFactory.createOperate('-');
Operation operMUL = OperationFactory.createOperate('*');
Operation operDIV = OperationFactory.createOperate('/');
operADD.numberA = 15.0;
operADD.numberB = 3;
System.out.println(operADD.getResult());
System.out.println(operSUB.getResult());
System.out.println(operMUL.getResult());
System.out.println(operDIV.getResult());
}
}
因為抽象類是靜態(tài)方法 所以 給operADD 那個對象賦值一次就能獲得所有結(jié)果。要是去掉static 那么就需要每個對象 賦值?,F(xiàn)在基本滿足你的要求了。
第一空,因為本人知識不到家,不能根據(jù)你的驅(qū)動看出用的哪個數(shù)據(jù)庫,所以無法寫。
2.createStatement()
3.select * from 表名
4.executeQuery(sql)
5.long xh = rs.getLong(2)//數(shù)據(jù)類型(要看你第二字段的類型) 變量名=rs.get數(shù)據(jù)類型(2),這個不是很有把握
6.System.out.println(xh)
public static void main(String[] args) {
// 建立list列表
ListInteger list = new ArrayListInteger();
list.add(5);
list.add(2);
list.add(8);
// 轉(zhuǎn)數(shù)組
Object[] arr = list.toArray();
// 排序
Arrays.sort(arr);
// 輸出數(shù)組
for (Object i : arr) {
System.out.println(i);
}
// 輸出list
for (int i : list) {
System.out.println(i);
}
// 輸出list
for (int i = 0; i list.size(); i++) {
System.out.println(list.get(i));
}
// 建立map
MapString, String map = new HashMapString, String();
map.put("key1", "value1");
map.put("key2", "value2");
map.put("key3", "value3");
// 輸出map元素
for (String key : map.keySet()) {
String value = map.get(key);
System.out.println("key: " + key + "\tvalue: " + value);
}
}
當前名稱:java補代碼的題 java代碼自動補全
瀏覽地址:http://chinadenli.net/article14/dodijde.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供、用戶體驗、網(wǎng)站策劃、企業(yè)建站、品牌網(wǎng)站建設、品牌網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)