Skip to main content

Keywords


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!

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

Add new comment

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.