by Dinesh Thakur

Arrays:- When there is a need to use many variables then we There is a big problem because we will Conflict with name of variables So that in this Situation where we wants to Operate on many  numbers then we can use array .

Arrays are Set of Elements having Same data type or We can Say that Arrays are Collection of Elements having same name and same data type But Always Remember Arrays are Always


Start From its index value and the index of array is start From 0 to n-1. Suppose we wants to Access 5th Element of array then we will use 4th Element Because Arrays are Start From 0 and arrays are always stored in Continuous Memory Locations The Number of Elements and Types of array are Identified by Subscript of array Elements. The Various types of Array those are provided by java as Follows:-


1) Single Dimensional Array:- These are Mostly used when we wants to declare number of Elements Single Dimensional arrays are used for Using Many elements and they are Declared with Single Bracket Like int a [] etc. the Bracket will specify the size of array Elements Means how many array elements are declared and used For Accessing or using a variable we have to Specify the Index Value in the Sub Script or in Bracket  of Array Variable.


The [] is used for dimensional or the sub-script of the array that is generally used for declaring the elements of the array For Accessing the Element from the array we can use the Subscript of the Array like this



So there is only the single bracket then it  is called as Single Dimensional Array

The Syntax For Declaring Array Elements in java is as FollowsL-


            Int a[]=new int[5] 


Note the new Keyword this is a Special Operator Which is usef for Creating new Memory which is Continuous in nature and The new Keyword is Also Creating For Memory For Number of elements That is Specified in Single bracket.


2) Two Dimensional Array :- The Two Dimensional array Elements are used when we Wants to Perform the Operation in Matrix Forms the Two Dimensional arrays are used For Creating Matrix and  Displaying array elements in the Form of Rows and Columns The Total Elements of Arrays Will be Calculated by Multiplying the  Elements of Rows and Columns Like int a[3][3] i. e 9 Elements will be used by Array These are Called as Two Dimensional Because they use two Brackets.


Like this int a[3][3]


So This is the Example of the Two Dimensional Array  In this first 3 represents the total number of Rows and the Second Elements Represents the Total number of Columns  The Total Number of elements are judge by Multiplying the Numbers of Rows * Number of Columns in The Array in the above array the Total Number of elements are 9


The Two Dimensional arrays are Declared as Follows:-


                        Int a[][]=new int[3][3] .


String :- Like an integer characters are also be in the Array The Array of Characters are called as the Strings  They are Generally used for representing the Strings   in java String is Also Array and Also a Class .we Know that when Collection of Characters are called as String In java For Creating an String array You Will use as Follows:-


                        String s[]=new String[10];


Here is the s is an array of type String Means it can accept only 10 Characters but if you will use String as then:-


            String s==new String(“Welcome To Strings”)


S is an object of Class String and now you can use any Method From String Class The Various String Methods those are Reside in String Class are :-


  1. A.ToLowerCase:- For Converting a String into small letters or in small cases
  2. B.ToUpperCase:- For Converting a String into Upper letters or in Upper cases.
  3. C.Length:- For Calculating the Number of Characters in a String.
  4. D.Trim:- For Removing both left and Right Side Spaces.
  5. E.charAt:- For Finding aat the Position.
  6. F.indexOf:- For Finding the Position of a Character in a String.
  7. G.substring:- For Extracting a string from a string.
  8. H.replace:- For Replacing a Character in the String.
  9. I.compareTo:- For Comparing a String With another,
  10. J.Concat:- For Joining Two strings and Making a Single String.