Java / Android Developer, Trainer, Writer, Speaker

Saturday, January 24, 2015

On 10:12 AM by M Rubel in ,    5 comments

Like the article?

Array: An array is something more or less like a container of data. Array container contains same type of data.





Read More from Oracle >> Here!

Java Code for practicing:

import java.util.Arrays;
public class myarray {
public static  void main(String [] args) {

// declaring  an array in java
int[] javaArray = new int[10];

// array with values
String prof[] = {"lawyear", "engineer", "stupoid", "developer"};

// allowed but not preferred declaring java array
int buy[];
buy = new int[10];

// java array of numbers, integer
int javaNumberArray[] = {2,3,6,7,78,8};


int[] [] learn = { {1,2,3}, {4,5,6}, {7,8,9,81}, {10,11, 12} };
 

// how to print a java array length
System.out.println( " My Java Array leangth: "+ learn.length );

int s;
for( s=0; s < javaNumberArray.length; s++ ) {

System.out.println( "My Array output, according to index is: "+ javaNumberArray[s] );


}




// printing a 2d array in java
int p,q;
for( p=0; p < learn.length; p++ ) {
for(q=0; q< learn[p].length; q++ ) {

System.out.println(  learn[p][q] );


}

}


for(int n: javaNumberArray) {
   System.out.println("My Arrar Java Number is: "+ n);




int[] seo = {1,2,23,3,3,3,4,4,5,6,67,7,8,89,9,76,4,33,3,32 } ;

// print a java array in one line
System.out.println( "Size of SEO ArrAy is: "+ Arrays.toString(seo)) ;

// print a java 2d ( 2 dimentional ) array in one line
System.out.println( "Size of 2D Learn ArrAy is: "+ Arrays.deepToString(learn)) ;





}
}






Output:

 My Java Array length: 4
My Array output, according to index is: 2
My Array output, according to index is: 3
My Array output, according to index is: 6
My Array output, according to index is: 7
My Array output, according to index is: 78
My Array output, according to index is: 8
1
2
3
4
5
6
7
8
9
81
10
11
12
My Arrar Java Number is: 2
My Arrar Java Number is: 3
My Arrar Java Number is: 6
My Arrar Java Number is: 7
My Arrar Java Number is: 78
My Arrar Java Number is: 8
Size of SEO ArrAy is: [1, 2, 23, 3, 3, 3, 4, 4, 5, 6, 67, 7, 8, 89, 9, 76, 4, 33, 3, 32]
Size of 2D Learn ArrAy is: [[1, 2, 3], [4, 5, 6], [7, 8, 9, 81], [10, 11, 12]]

5 comments:

  1. All are saying the same thing repeatedly, but in your blog I had a chance to get some useful and unique information, I love your writing style very much, I would like to suggest your blog in my dude circle, so keep on update.
    Web Development Company in India

    ReplyDelete
    Replies
    1. Thanks for the post, I am techno savvy. I believe you hit the nail right on the head. I am highly impressed with your blog. It is very nicely explained. Your article adds best knowledge to our Java Online Training from India. or learn thru Java Online Training from India Students.

      Delete
  2. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon.

    Best Dental Clinic in Chennai | Best Dentists in Chennai | Dental Hospital in chennai

    ReplyDelete
  3. very very amazing explaintion....many things gather about yourself...yes realy i enjoy it
    SEO Company in India

    ReplyDelete
  4. Congratulations guys, quality information you have given!!!..Its really useful blog. Thanks for sharing this useful information..Thankyou For shearing This Information With Us.
    Web Development Services in Bangalore
    BEST web design services in bangalore
    ECommerce Website developers in bangalore
    Outsource magento ecommerce services india

    ReplyDelete