Introduction To Programming: Intro To Java Programming Language For Beginers

Welcome to this java class, this tutorial is basically for those who are new to java, if you know any other programming language before learning java is an added advantage, since all programming language are alike with slit change in syntax.

You Will Need To Read About:

Things You Will Need:

  • A java JDK application Download from here
Lets begin.

There are two kinds of java programs:

  • Applets
  • Application. 

An Application or Application Program is just a regular program you already know while the Applets means a little java application.

Applets and application are almost identical. The difference is that applications are meant to be run on your computer like any other program, whereas an applet is meant to be run from a web browser and so can be sent to another location on the internet and run there. An applet can be also run with an applet viewer.

An applet always has a windowing interface while an application program may have a windowing interface or use simple console input/Output (I/O).

A java program is really a class definition with a method named main. When the program is run, the method named main is invoked; that is, in braces, {}, so that when the program is run, the statements in the braces are executed.

An Example of a Java Application Program:

The following line below says that this program is a class called FirstProgram:

pubic class FirstProgram 
{

The next two lines, shown below, begin the definition of the main methods:

public static void main(String[] args)
{

The next two lines, shown below are the first actions the program performs:

System.out.println("Hello Reader.");
System.out.println("Welcome to java");

system.out.println makes the string given within the parentheses ("Hello Reader.") to be output to the screen.
system.out is an object used for sending output to the screen while println is a method that tells the program what to perform.

Java Variables:

Variable declarations in java are similar to what they are in other programming languages. 

Example: 

int answer;


Java Data Types
Type Name Kind Of Value Memory Used Size Range
boolean true or false 1 byte not applicable
char single character (Unicode) 2 bytes all Unicode characters
byte integer 1 byte -128 to 127
short integer 2 bytes -32768 to 32767
int integer 4 bytes -2147483648 to 2147483647
long integer 8 bytes -9223372036854775808 to
9223372036854775808
float floating-point number 4 bytes-(+-)3.40282347*10^(+38) to
(+-)1.40282347*10^(-45)
double floating-point number 8 bytes (+-)(+-)1.7676931386231570*10^(+308) to
(+-)(+-)4.9406545841246544*10^(-324)

Java Byte-Code and Java Virtual Machine (JVM):

Java compiler does not translate your program into machine language for your particular computer. instead it translates your java program into a language called the byte-code.

Byte-code is not the machine language for any particular computer. Byte-code is the machine language for a fictitious computer called the Java Virtual Machine (JVM). 

The Java Virtual Machine is very similar to all typical computers. Thus, it is guage for any particular computer. The program that does this translation is called an Interpreter.

An interpreter combines the translation of the byte-code and the execution of the corresponding machine-language instructions. The interpreter works by translating an instruction of byte-code into instructions expressed in your computer's machine language and then executing at a time. Thus, an interpreter translates and executes the instructions in the byte-code one after the other, rather than translating the entire byte-code program at once.

How To Compile and Run A Java Program:

  • First, you use the compiler to translate the java program into byte-code.
  • Then, you use the byte-code interpreter for your computer to translate each byte-code instruction to machine language and to run the machine-language instruction.

Steps To Compile and Run a Java Program:

  1. Save your java source code into the java jdk folder with .java file extension like FirstProgram.java
  2. Run Command Line Console (CMD) by pressing your windows key and R key, type CMD and Hit Enter
  3. change the directory to the java JDK folder.
  4. To compile your source code: Enter 
  5. javac FirstProgram.java 
  6. Note: FirstProgram.java will be the name you used in saving your source code.
  7. To Run Your Program: Enter
  8. java FirstProgram
  9. Note: FirstProgram will be the name you used in saving your source code.


Introduction To Programming: Intro To Java Programming Language For Beginers Introduction To Programming: Intro To Java Programming Language For Beginers Reviewed by Chukwumah Rapheal on September 22, 2016 Rating: 5

No comments:

.:: Place Comment With the Commemnt Box and Share This Post With The Share Buttons. Thanks::.

RaphBlog.Com.NG. Powered by Blogger.