A closer look at methods and classes

327 views
280 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
327
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

A closer look at methods and classes

  1. 1. A closer look at Methods and Classes
  2. 2. Understanding the static keyword… Normally methods, or class members, are accessed in conjunction with an object of its class. However, it is possible to create a “member” that can be used by itself... … without reference to a specific instance.
  3. 3. To create such a member, precede its declaration with the keyword static. The most common example of a static member is the main( ). main ( ) is declared as static because it must be called before any objects exist. but Methods declared as static have several restrictions: <ul><ul><li>They can only call other static methods. </li></ul></ul><ul><li>They must only access static data. </li></ul><ul><li>They cannot refer to this or super in any way. </li></ul>

×