Total members 10261 | Gratitudes |It is currently Tue May 22, 2012 4:49 pm Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 1 post ] 
Author Code Snippet
 Code subject: creating arrays in java
PostPosted: Thu Jan 29, 2009 1:19 am 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2279
Location: Earth
Has thanked: 39 time
Have thanks: 61 time

Creating arrays in java :
Arrays are objects in java ,and for that we create them using new operator .

For primitive data types :
Code:

    int[] myarr=new int[3];



For not primitive data types :

Code:

  car[] mycars=new car[3];



Once you specify the size of arrays , you can't change it later .

Assign values to arrays :
Code:
       

        myarr[0]=32;
        myarr[1]=12;
        myarr[2]=50;



for non primitive types :

Code:
       

        mycars[0]=new car("BMW");
        mycars[1]=new car("VOLVO");
        mycars[2]=new car("FIAT");



Create objects in the heap and assign it to the the array elements .

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 1 post ] 
Quick reply


  

 Similar topics
 Defining arrays in ASP
 video chat application in java
 navigating to database using java
 java mobile apps
 need help in java
 Read your gmail using Java code
 Java Programing to communicating port parallel
 Java Chat
 Steganography in java
 java code for listing folder contents from remote folder

All times are UTC [ DST ]


Users browsing similar codes

Users browsing this forum: No registered users and 2 guests



Jump to:  
Previous Code Snippet | Next Code Snippet 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team