Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Java syntax
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Literals=== {| class="wikitable" |- !colspan="2"|Integers |- ![[Binary numeral system|binary]] (introduced in Java SE 7) |{{mono|0b11110101}} ({{mono|0b}} followed by a binary number) |- ![[octal]] |{{mono|0365}} ({{mono|0}} followed by an octal number) |- ![[hexadecimal]] |{{mono|0xF5}} ({{mono|0x}} followed by a hexadecimal number) |- ![[decimal]] |{{mono|245}} (decimal number) |- !colspan="2"|[[Floating-point]] values |- !rowspan="2" | float |{{mono|23.5F}}, {{mono|.5f}}, {{mono|1.72E3F}} (decimal fraction with an optional exponent indicator, followed by {{mono|F}}) |- |{{mono|0x.5FP0F}}, {{mono|0x.5P-6f}} ({{mono|0x}} followed by a hexadecimal fraction with a mandatory exponent indicator and a suffix {{mono|F}}) |- !rowspan="2" | double |{{mono|23.5D}}, {{mono|.5}}, {{mono|5.}}, {{mono|1.72E3D}} (decimal fraction with an optional exponent indicator, followed by optional {{mono|D}}) |- |{{mono|0x.5FP0}}, {{mono|0x.5P-6D}} ({{mono|0x}} followed by a hexadecimal fraction with a mandatory exponent indicator and an optional suffix {{mono|D}}) |- !colspan="2"|Character literals |- !char |{{mono|'a'}}, {{mono|'Z'}}, {{mono|'\u0231'}} (character or a character escape, enclosed in single quotes) |- !colspan="2"|Boolean literals |- !boolean |{{mono|true}}, {{mono|false}} |- !colspan="2"|null literal |- !null reference |{{mono|null}} |- !colspan="2"|String literals |- !String |{{mono|"Hello, World"}} (sequence of characters and character escapes enclosed in double quotes) |- !colspan="2"|Characters escapes in strings |- ![[Unicode]] character |{{mono|\u3876}} ({{mono|\u}} followed by the hexadecimal unicode code point up to U+FFFF) |- ![[Octal]] escape |{{mono|\352}} (octal number not exceeding 377, preceded by backslash) |- ![[Line feed]] |{{mono|\n}} |- ![[Carriage return]] |{{mono|\r}} |- ![[Form feed]] |{{mono|\f}} |- ![[Backslash]] |{{mono|\\}} |- ![[Single quote]] |{{mono|\'}} |- ![[Double quote]] |{{mono|\"}} |- ![[Tab character|Tab]] |{{mono|\t}} |- ![[Backspace]] |{{mono|\b}} |} Integer literals are of <code>int</code> type by default unless <code>long</code> type is specified by appending <code>L</code> or <code>l</code> suffix to the literal, e.g. <code>367L</code>. Since Java SE 7, it is possible to include underscores between the digits of a number to increase readability; for example, a number {{mono|145608987}} can be written as {{mono|145_608_987}}.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)