Your SlideShare is downloading. ×
0
12 java modifiers
12 java modifiers
12 java modifiers
12 java modifiers
12 java modifiers
12 java modifiers
12 java modifiers
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

12 java modifiers

65

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
65
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. JAVA MODIFIERS Talk 12
  • 2. ACCESS MODIFIERS • private: only this class • protected: subclasses, classes in same package • public: every class • default: classes in same package
  • 3. FINAL • on a field: can be (and needs to be) assigned only once • on a method: cannot be reimplemented • on a class: cannot have subclasses
  • 4. STATIC • on a field or method: the field or method belongs to the class (not to the instance) • static block: initializes static fields class Foo { private static int baz; ! static { baz = 10; } }
  • 5. TRANSIENT • on a field: will not persisted during serialization
  • 6. SYNCHRONIZED • on a method: can be executed by only a thread at a time • the lock is on the instance on which the method is invoked
  • 7. VOLATILE • on a field: tells the compiler that the field can be modified unexpectedly by another thread; • it is not stored in CPU caches.

×