CORE JAVA: The Java Language

Introduction

Java is a general-purpose computer programming language that is concurrent, class-based, object-oriented, and specifically designed to have as few implementation dependencies as possible.One of the most popular programming languages in use.Derives much of its syntax from C and C++.

Features of Java:

  1. Compiled and Interpreted: Java is a compiled programming language, but rather than compile straight to executable machine code, it compiles to an intermediate binary form called JVM bytecode. The bytecode is then compiled and/or interpreted to run the program.
  2. Platform-Independent and Portable: On compilation, Java program is compiled into bytecode. This bytecode is platform independent and can be run on any machine, plus this bytecode format also provides security. Any machine with Java Runtime Environment can run Java Programs.
  3. Simple, Object-oriented and Familiar: Java is easy to learn and its syntax is quite simple, clean and easy to understand.The confusing and ambiguous concepts of C++ are either left out in Java or they have been re-implemented in a cleaner way.In Java, everything is Object which has some data and behavior. Java can be easily extended as it is based on Object Model.
  4. Robust and Secure: Robust simply means strong. Java uses strong memory management. There is lack of pointers that avoid a security problem. There is automatic garbage collection in java. There are exception handling and type checking mechanism in java. All these points make java robust.When it comes to security, Java is always the first choice. With java secure features it enables us to develop virus-free, temper free system. Java program always runs in Java runtime environment with almost null interaction with system OS, hence it is more secure.
  5. Distributed: We can create distributed applications in Java. RMI and EJB are used for creating distributed applications. We may access files by calling the methods from any machine on the internet.
  6. High Performance: Java is faster than traditional interpretation since bytecode is “close” to native code still somewhat slower than a compiled language (e.g., C++).
  7. Multithreaded: Java multithreading feature makes it possible to write a program that can do many tasks simultaneously. The benefit of multithreading is that it utilizes same memory and other resources to execute multiple threads at the same time, like While typing, grammatical errors are checked along.

Java programming format:

..

Java Tokens:

bdfb

 

Java Statements:

stat

Java Data Types:

datatype Primitive-Data-Types-in-Java-Programming-Language

Typecasting:

type-casting-in-c-programming-2-638

Example :

int x = 10;
byte y = (byte)x;

Arrays:

tokem

Types of Array in Java:

There are two types of array.

  • Single Dimensional Array
  • Multidimensional Array
  • Single Dimensional Array in java

  • Syntax to Declare an Array in java

 

  1. dataType[] arr; (or)  
  2. dataType []arr; (or)  
  3. dataType arr[];  
  • Instantiation of an Array in java

        arrayRefVar=new datatype[size];  

An example of single dimensional Java array:

Let’s see the simple example of java array, where we are going to declare, instantiate, initialize and traverse an array.

stat

OUTPUT:

stat

ff

  •   Multidimensional array in java

In such case, data is stored in row and column based index (also known as matrix form).

  •     Syntax to Declare Multidimensional Array in java 

            dataType [][]arrayRefVar; (or)  

           dataType arrayRefVar[][]; (or)  

           dataType []arrayRefVar[];   

  • Example to instantiate Multidimensional Array in java

     

    1. int[][] arr=new int[3][3];//3 row and 3 column  

    Example to initialize Multidimensional Array in java

     

    1. arr[0][0]=1;  
    2. arr[0][1]=2;  
    3. arr[0][2]=3;  
    4. arr[1][0]=4;  
    5. arr[1][1]=5;  
    6. arr[1][2]=6;  
    7. arr[2][0]=7;  
    8. arr[2][1]=8;  
    9. arr[2][2]=9;  

    Example of Multidimensional java array

    Let’s see the simple example to declare, instantiate, initialize and print the 2Dimensional array.

    ngh

OUTPUT:

nm

 

 

 

Advertisements

4 thoughts on “CORE JAVA: The Java Language

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s