java中的單引號和雙引號

來源:互聯網
上載者:User

標籤:

1、單引號引的資料 是char類型的,雙引號引的資料 是String類型的;單引號只能引一個字元,而雙引號可以引0個及其以上。char只是一個基本類型,而String 可以是一個類,可以直接引用。
比如char c=‘c‘;不能直接對c調用方法。
String s="abc";  這時可以調用s.charAt(0);等方法,因為String是類,這是就是對象的調用了

2.在sql語句中單引號可以標識文本型的資料。都是界符,用來標識它們引用資料的開始和結束。另外java中的sql裡傳變數時使用單引號界定引進的變數:
  String sql = "select **** from *** where ** =‘   "  +變數+  "   ‘   ";

3、下面這個SQL語句中(SqlServer)中似乎就是有將單引號放到雙引號中的嫌疑就是將‘chStr.chStr(g.getGoodsName())‘變成整體,順便每個值中用“,”隔開

String sql = "Insert into tb_goods (TypeID,GoodsName,Introduce,Price,nowPrice,picture,newgoods,sale) values(" +
g.getTypeID() + ",‘" + chStr.chStr(g.getGoodsName()) + "‘,‘" +//調用chStr對象調用chStr方法時用:‘chStr.chStr(g.getGoodsName())‘
chStr.chStr(g.getIntroduce()) + "‘," + g.getPrice() + "," +
g.getPrice() + ",‘" + chStr.chStr(g.getPicture()) + "‘," +
g.getNewGoods() + "," + g.getSale() + ")";

java中的單引號和雙引號

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.