aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes for loop problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "for loop problem" Watch "for loop problem" New topic
Author

for loop problem

geet kaur
Ranch Hand

Joined: Sep 03, 2008
Posts: 78

aren't both the for loops initialisng the array elements?
Harshit Rastogi
Ranch Hand

Joined: Apr 15, 2008
Posts: 131
the jdk1.5 for loop is used for read only purpose and not the changes the data or values.


<a href="http://technologiquepanorama.wordpress.com" target="_blank" rel="nofollow">My Techie Blog</a><br /><a href="http://www.java-questions.com" target="_blank" rel="nofollow">Java Questions</a>
geet kaur
Ranch Hand

Joined: Sep 03, 2008
Posts: 78
hey thanks !!!
got it
Manju Kavi
Ranch Hand

Joined: Sep 25, 2008
Posts: 33
for each loop is used for iterating purpose, an advanced version of old for loop..
suresh pilakal babu
Ranch Hand

Joined: Jul 01, 2008
Posts: 31
Hi Geet,

In below for loop

for(Dog a og){
a=new Dog();
}//but if i use this one then the output is null

you are not initialising dog array, but you are assign the Dog object to the variable 'a'. thats why displaying 'null'.

if you want to initialse dog array you have modify like this

int i = 0;
for(Dog a og){
a=new Dog();
dog[i++] = a;
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: for loop problem
 
Similar Threads
K&B Static Method Redifinition Problem..
Where is this line coming from??
Illegal start of expression compilation error
Downcasting
generics