Java Reference

Java Reference Home | Smart Soft Home

Single Quotes '
Single quotes have two purposes in Java.

Description 1

Used to indicate a char literal.

Examples

System.out.println('S');  //'S' is a char literal
char x = 'H'; //'H' is a char literal

Description 2

Used to place quotes inside of quotes for JDBC SQL statements.

Example 2

PreparedStatement ps = conn.prepareStatement("SELECT * FROM Companies WHERE CompanyName = 'Sun'");