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
  2. Platform-Independent and Portable
  3. Simple, Object-oriented and Familiar
  4. Robust and Secure
  5. Distributed
  6. High Performance
  7. Multithreaded
  8. Dynamic and Extensible

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

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];  

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

 

 

 

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