这样的字段里怎么取值?? 122123|254|258|36958|147125487|369854|12574125487|2569894|4587545|58475| 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 目前数据库里这样两字段上班 001迟到|早退|休假 a1|a2|a3我现在想实现 上班-001 迟到-a1,早退-a2,休假-a3这样的数据怎么合并?? 只供参考,写得不好的地方还忘见谅------------------------------------/** * project_name: Test * package_name: netsource * package_declaration: package netsource; * filename: DateOpposite.java * author: yuhaiming * date: 2007-11-14 *//** * 目前数据库里这样两字段 上班 001 迟到 ¦早退 ¦休假 a1 ¦a2 ¦a3 我现在想实现 上班-001 迟到-a1,早退-a2,休假-a3 这样的数据怎么合并?? */package netsource;import java.io.*;public class DateOpposite { public static void disposal(String strvalue1,String strvalue2){ String strresult = ""; int count1 =-1,count2=-1; while((count1 =strvalue1.indexOf("¦"))>0&&(count2 =strvalue2.indexOf("¦"))>0){ strresult += strvalue1.substring(0,count1).trim()+"-"+strvalue2.substring(0,count2).trim()+"&"; strvalue1 = strvalue1.substring(count1+1); strvalue2 = strvalue2.substring(count2+1); } strresult += strvalue1+"-"+strvalue2; String[] result = strresult.split("&"); display(result); } public static void display(String[] result){ for(int i=0;i<result.length;i++){ System.out.println(result[i]); } } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub String strvalue1 = "迟到 ¦早退 ¦休假";//从数据库取值,这里为了方便直接赋值了 String strvalue2 = "a1 ¦a2 ¦a3";//从数据库取值,这里为了方便直接赋值了 disposal(strvalue1,strvalue2); }} 晕....不用这么麻烦吧.....public class test { public test() { String a = "123|234|345"; String b[] = a.split("|"); for(String c:b) System.out.println(c); } public static void main(String[] args) { new test(); }}可以招这样的思路做 ...........程序写错了....失误啊......上面的 a.split("|")应该是a.split("\\|");忘了转义字符了.... 目前数据库里这样两字段 上班 001 迟到 ¦早退 ¦休假 a1 ¦a2 ¦a3 我现在想实现 上班-001 迟到-a1,早退-a2,休假-a3 这样的数据怎么合并??select t.上班 || '-' || t.001 from table t 3个数2个相同输出不同的那个 DefaultTableModel的问题 空指针异常 java 程序 textarea 粗体和斜体 给个重载repaint的例子咯,谢谢!!!! 如何做一组单选的按钮? 不知是我写错了,还是java有漏洞??????,不能用ASCII 30 做分隔符 怎么取得Windows下的某个进程的CPU运行情况 关于邮件群发的几个问题? java获取CPU利用率时报错,大神们,帮帮忙 求教,如何写一个像windows xp开机时的进度条? jfreechart中折线图的横轴数据点太多,怎么能加一个滚条,并且设置最小间距?否则显示太模糊了。
迟到|早退|休假 a1|a2|a3
我现在想实现
上班-001
迟到-a1,早退-a2,休假-a3
这样的数据怎么合并??
------------------------------------/**
* project_name: Test
* package_name: netsource
* package_declaration: package netsource;
* filename: DateOpposite.java
* author: yuhaiming
* date: 2007-11-14
*/
/**
* 目前数据库里这样两字段
上班 001
迟到 ¦早退 ¦休假 a1 ¦a2 ¦a3
我现在想实现
上班-001
迟到-a1,早退-a2,休假-a3
这样的数据怎么合并??
*/
package netsource;
import java.io.*;
public class DateOpposite {
public static void disposal(String strvalue1,String strvalue2){ String strresult = "";
int count1 =-1,count2=-1;
while((count1 =strvalue1.indexOf("¦"))>0&&(count2 =strvalue2.indexOf("¦"))>0){
strresult += strvalue1.substring(0,count1).trim()+"-"+strvalue2.substring(0,count2).trim()+"&";
strvalue1 = strvalue1.substring(count1+1);
strvalue2 = strvalue2.substring(count2+1); }
strresult += strvalue1+"-"+strvalue2;
String[] result = strresult.split("&");
display(result);
}
public static void display(String[] result){
for(int i=0;i<result.length;i++){
System.out.println(result[i]);
}
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String strvalue1 = "迟到 ¦早退 ¦休假";//从数据库取值,这里为了方便直接赋值了
String strvalue2 = "a1 ¦a2 ¦a3";//从数据库取值,这里为了方便直接赋值了
disposal(strvalue1,strvalue2);
}}
public class test {
public test() {
String a = "123|234|345";
String b[] = a.split("|");
for(String c:b)
System.out.println(c);
}
public static void main(String[] args) {
new test();
}
}
可以招这样的思路做
上面的 a.split("|")应该是a.split("\\|");
忘了转义字符了....
迟到 ¦早退 ¦休假 a1 ¦a2 ¦a3
我现在想实现
上班-001
迟到-a1,早退-a2,休假-a3
这样的数据怎么合并??
select t.上班 || '-' || t.001 from table t