Difference between revisions of "Misc"

From Suhrid.net Wiki
Jump to navigationJump to search
Line 16: Line 16:
 
* int __;
 
* int __;
 
* String $;
 
* String $;
 +
 +
Literals
 +
 +
* Default type of an integer literal is int.
 +
* Long can be specified by adding l or L
 +
* Octal prefix with 0
 +
* Hex prefix with 0x or 0X
 +
* Floating point literals default type is double.
 +
* Double can also be explicitly by adding the suffix d or D
 +
* Float is denoted by suffix f or F
 +
  
 
[[Category:OCPJP]]
 
[[Category:OCPJP]]

Revision as of 23:33, 20 June 2011

This covers Objective 1.3

Legal Identifiers

  • Can be composed of characters, numbers, currency-symbols and connecting chars such as underscore.
  • Definition of characters are interpreted according to the charset.
  • NO special chars such as #, :, ;, @, -, etc...
  • Must start with letter, currency char, underscore but CANNOT start with a digit !
  • Java identifiers are case-sensitive.

Illegal identifiers:

  • int 23age;
  • String em@iladd;
  • List all-accounts;

These are legal!:

  • int __;
  • String $;

Literals

  • Default type of an integer literal is int.
  • Long can be specified by adding l or L
  • Octal prefix with 0
  • Hex prefix with 0x or 0X
  • Floating point literals default type is double.
  • Double can also be explicitly by adding the suffix d or D
  • Float is denoted by suffix f or F