Starting Java
Java is very handy and widely used language as per now. Why? well there are several aspects to it like
- Easy coding
- Cross-Platform
- Wide support in many devices
Hence it is very useful to both, programmer and user. As it is easy so we can just about make anything in java. That's very powerful thing about java. Because it gives easy functionality via libraries to major computer functionality as follows
- GUI (Graphical User Interface)
- Audio (playing audio)
- Video (video play)
- Network (internet access)
- File Handling (working with files)
Cross-Platform:
What does that mean? it simply mean we can run java build programs on various machines, Linux, mac-OS, Windows etc. That mean you can make it's program in Windows and just give it to a mac-Os user and he will be able to run it just fine on mac-Os as well. That functionality is one unique feature of java. Now a days many libraries are coming for java to make it more useful in many ways.
Libraries:
Libraries have major role in Java. Because pretty much anything you want to do in Java you will have some library for it. Apart from usual code only other complex coding which a programmer can face is hardware interaction. And Java handles it perfectly but it is a bit heavy in old computers.
To include libraries in Java program we use import statement.
import library name
Example:
import javax.swing.*;
That * sign in import statement is used to import all functions of a particular library. For example i want to use math functions so what I'll do is to put * after it and all functions will be available for use.
Since java is library based so it is very easy to search it's information more than any other language.
Class and Package:
While programming, it is a good practice to arrange the code in some
way that it is easy to work with. Some might think he doesn't need to
but in beginning we write just sample codes to understand it's
functionality thus we don't really need to do that but when it becomes
to write a whole software, arranged code is of primary importance
because it has 2 major uses:
- Code arrangement
- Step by step coding
Step by step coding is that
when you have to implement many functions via code it's hard to do all
at once. So here namespaces come in, we divide code by it's
functionality and length and then give them to separate namespaces. For
example if I'm making a game and it has some major functionality to be
implemented by code. Let's have a look at it:
- Graphics
- User input
- Game data
- User information
- Game files, sounds and maps etc.
Packages are a little bit higher level of arrangement. Basically they are not such a hard thing to understand. They are used to divide code in Major parts. Like if a program uses 2 type of major functions being Graphics and Networking then we will put Graphics code (which is written various classes) to one package named Graphics and similarly for Networking.
Main:
In every program written in any programming language you will encounter
a word 'main' which defines start of program. It is obvious any process
starts from some point. In programming we define this start point as
main. It is the beginning code that starts running when user opens a
program. It is called main method, the program will start running from this part.
We declare main like this:
public static void main(String [] args) {
}
You don't need to worry about it's size. It is always the same so you don't need to understand it in order to run the program.
Comments
Post a Comment