Single and double quotation marks in Java

Source: Internet
Author: User

1, the single quotation marks the data is a char type, double quotation marks the data is a string type, single quotation marks can only one character, and double quotation marks may be cited 0 and above. Char is just a basic type, and string can be a class that can be referenced directly.
such as Char c= ' C '; The method cannot be called directly on C.
String s= "ABC"; You can call S.charat (0), and so on, because string is the class, and that is the object's call.

2. Single quotes in SQL statements can identify text-type data. are bounded characters that identify the beginning and end of their reference data. In addition, SQL in Java uses single quotes to define the variables that are introduced:
String sql = "SELECT * * * * * FROM where * * = ' " + variable + " '";

3, in the following SQL statement (SQL Server) appears to have the single quotation mark in double quotation marks is the suspicion that the ' Chstr.chstr (G.getgoodsname ()) ' into the whole, by the way each value is "," separated

String sql = "Insert into Tb_goods (Typeid,goodsname,introduce,price,nowprice,picture,newgoods,sale) VALUES ( " +
G.gettypeid () + ",'" + chstr.chstr (G.getgoodsname ()) + "', '" +//Call Chstr object when calling Chstr method with: ' Chstr.chstr ( G.getgoodsname ()) '
Chstr.chstr (G.getintroduce ()) + "'," + g.getprice () + "," +
G.getprice () + ", '" + Chstr.chstr (G.getpicture ()) + "'," +
G.getnewgoods () + "," + g.getsale () + ")";

Single and double quotation marks in Java

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.