Main areas of learning Java programming
Saturday 27 February 2016, by Shahid Khan
Learning to programme in Java is fun but at the same time quite challenging, as we are familiarising with different concepts that makes up the whole Java technology and its structure.
When you start learning Java, you have to understand that you have to make yourself knowledgeable in different areas. Here we discussed what to expect when you learn Java. I have divided the learning topics into four categories: syntax, keywords, object orientation and Application Programming Interface (APIs).
Syntax
First is the syntax of the programming language. By syntax we mean the different grammatical rules of writing the programme. It includes rules for declaring classes, variables and methods. You will how to provide parameters to methods and making methods available to be used from anywhere in the code. Further how to invoke different methods and pass them with actual data which also know as arguments.
The two most important things you do learn are how to control the blocks of code. In programming they are called control structures.
The control structures are further divided into two mechanisms Selection and Iteration (Loops).
Selection is all about making decisions. To implement selection control in program we use if and switch statements. Statements in program are executed in sequence which is called sequential execution. By adding the selection statement we can actually alter the normal control flow of the program. Which course or path to select, skip or execute will be determined by some sort of test.
Iteration is to repeat a certain block on code for fixed or flexible times. To implement iteration, repetition or loop we use while, do-while and for statements. Again the repetition will perform some sort of test on each round to determine whether to continue to repeat the block of code or not. Another strategy can be used is which is known as recursion.
Keywords
Keywords are reserved words in Java that are used to write the programs and have special meaning with-in the code context where they are written. Below is the complete list of Java keywords.
abstract |
continue |
for |
new |
switch |
assert*** |
default |
goto* |
package |
synchronized |
boolean |
do |
if |
private |
this |
break |
double |
implements |
protected |
throw |
byte |
else |
import |
public |
throws |
case |
enum**** |
instanceof |
return |
transient |
catch |
extends |
int |
short |
try |
char |
final |
interface |
static |
void |
class |
finally |
long |
strictfp** |
volatile |
const* |
float |
native |
super |
while |
I will explain few here:
Keyword class is used in the declaration and hence creating a class.
Keywords if and switch is used to implement the selection in the code, they are followed by tests conditions and code body to execute.
Keywords for, while and do are used to implement the iteration within the code
Keywords public, private and protected acts as access modifiers and are applied to classes, variables and methods.
Keywords byte, short, int and long are used to mark the data as an integer number by providing different sizes/ranges.
Keywords double and float are used to mark the data as an decimal number by providing different sizes/ranges.
Keyword boolean is used to track the true/false condition and therefore it has only to possible values true or false.
Keyword char is another data type to hold a single character.
Similarly all of the rest keywords have special purpose and meaning with-in the coding context and are used as and when required when solving a particular problem. You will learn and know there uses as you keep writing programs in Java.
Object Orientation
It is software development methodology in which we create and develop a program as a group of objects and these objects communicate with each other by calling each other methods and therefore running the overall system.
Knowing about Object Orientation will help you to write the programs that are easy to extend, reuse and debug.
The key concepts in the object orientation are to create an object as a single entity that has its own data and an interface to interact and manipulate its data. But to create objects we must define the guidelines or some sort of template that is used to create multiple copies of objects. But each object is different and unique and exits on its own.
To master the object orientation we need to further understand the concepts of Inheritance, Encapsulation, Abstractions and Polymorphism. We have a dedicated course at London Academy of IT that prepares you to write the programs using these object orientation techniques.
By following the object orientation rules we can create and develop almost every type of object virtually.
Application Programming Interface (API)
API is vital to the success and popularity of the language. Java has one of the huge and rich API, that provides you read to use software components.
You can import them into your programs and customise them according to your needs. In the meantime you can focus on other important feature of the system.
At present Java API 8 is the updated version. You can find all the provided API components on online Java 8 documentation. More information on this can be found here: https://docs.oracle.com/javase/8/docs/api/
API arranges these components (which are actually classes and interfaces) into packages. Packages make them easy to categorise, locate and use. For example, if you want to do event driven programming using Java you can use java.awt and javax.swing packages.
Further if you want to read and write to different types of file using streams, you can use java.io package.
If you fancy connecting to the database, and perform all the CRUD functions, that is create, read, update and delete the records then java.sql package is available to do it.
So to write efficient code and develop robust systems we need to make sure that we are writing correct syntax, proper use of keywords, good object orientation techniques and making full use of the Java API.