Skip to content

Commit 8046bcf

Browse files
author
Ram swaroop
committed
added content
1 parent 4239587 commit 8046bcf

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

_posts/2015-05-14-variables-and-literals.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,22 @@ figure below:
4343

4444
### Literal Values for All Primitive Types
4545

46-
A __primitive literal__ is merely a source code representation of the primitive data typesin other words, an integer,
47-
floating-point number, boolean, or character that you type in while writing code. The following are examples of
46+
A __primitive literal__ is merely a source code representation of the primitive data types, in other words, an integer,
47+
floating-point number, boolean, or character etc. that you type in while writing code. The following are examples of
4848
primitive literals:
4949

5050
{% highlight java %}
51+
127 // byte literal
52+
376 // short literal
53+
4290 // int literal
54+
58L // long literal
55+
2546.343f // float literal
56+
2546789.343 // double literal
5157
'b' // char literal
52-
42 // int literal
5358
false // boolean literal
54-
2546789.343 // double literal
5559
{% endhighlight %}
5660

57-
**Integer Literal**
61+
####Integer Literals
5862

5963
There are four ways to represent integer numbers in the Java language: decimal (base 10), octal (base 8),
6064
hexadecimal (base 16), and from Java 7, binary (base 2).
@@ -73,6 +77,13 @@ int i1 = _1_000_000; // illegal, can't begin with an "_"
7377
int i2 = 10_0000_0; // legal, but confusing
7478
{% endhighlight %}
7579

80+
NOTE: You can use the underscore character for any of the numeric types (including doubles and floats), but for
81+
doubles and floats, you CANNOT add an underscore character directly next to the decimal point.
82+
83+
**Decimal Literals**
84+
85+
86+
7687

7788

7889

0 commit comments

Comments
 (0)