---
title: "JAVA判断不等于空的情况"
author: "duyunfengsolo"
date: "2010-08-12T09:49:17Z"
tags: []
categories: ["编程语言"]
slug: "java"
draft: false
lastmod: "2011-05-26T14:16:21Z"
id: 735156
url: "https://solodu.iteye.com/blog/735156"
---

判断不等于空的情况，千万不要搞混淆。

if(orderId != null && !"".equals(orderId))  中间不是||的关系，是&&的关系。

 

\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__

java正则表达式去掉最后的“,”号。

       String custId = "";

       for(CustInfo cust : custList){  
           custId += cust.getId().toString() + "," ;  
        }

        custId = custId.replaceAll( ",$", "" );

 

JS正则表达式去掉最后的“,”号

String.prototype.replaceAll = function (AFindText,ARepText){  
        raRegExp = new RegExp(AFindText,"g");  
        return this.replace(raRegExp,ARepText);  
 }

var system\_ids = document.getElementsByName("system\_ids");  
 var systemvalue="";  
 if(system\_ids.length&gt;0){  
  for(var i=0;i&lt;system\_ids.length;i++){  
   if(system\_ids\[i].checked){  
    system\_value = system\_value + system\_ids\[i].value + ",";  
   }  
  }  
 }  
 system\_value = system\_value.replaceAll( ",$","" );  
 if(system\_value.length&gt;0){  
  sql = sql + " and t.system\_ids='"+ system\_value +"'";  
 }