Keywords

Submitted by: 
Language: 

Introduction:
This page will talk about Java keywords including Return, Public, Private, Static and Case.

What are keywords?
The keywords in Java are used to serve a certain purpose (depending on which keyword is used). Not all keywords are used in the same places and some are bound to certain statements.

Consistencies
The only thing these keywords have in common is that when they are used, they must be in complete lower case. Any upper-case letters will cause the keyword to void.

Return
I have already created a tutorial dedicated to the use of the return keyword and so I recommend you go and read that one separately. In short, this keyword is used in a method to send a value back to the position of calling the method.

Public or Private?
Public and Private can both be used in the same place, but only one may be chosen. These keywords are used to select the publicity of a certain method or variable. If a method or variable is public, the method or variable in question may be used from any other class or package which imports the containing class. If a method or variable is private, it may only be accessed from the same class it is contained in.

Static
A static keyword can be used in conjunction with a public or private keyword. If a method or variable is static it means there is only one instance of that particular method or variable, and so static can not be used in a Object Oriented Programming class.

Case
The case keyword is used in a Switch statement and is used to state a certain condition of the Switch statement. For example; a switch statement on the integer "i", the case for when i equals 1 would be "case 1:".

There are many other keywords in Java, all of which serve a purpose, but these are the most commonly used ones.

Finished!


Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.