Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-28-2012, 10:05 PM   PM User | #1
dannyboi
New Coder

 
Join Date: Jul 2012
Location: NYC
Posts: 23
Thanks: 1
Thanked 0 Times in 0 Posts
dannyboi is an unknown quantity at this point
This code compiles empty, meaning there is really no output. Can anyone explain why?

This code compiles empty. Can anyone explain why?
class ArrayDemo {
public static void main(String[] args) {
// declares an array of integers length "size"
int[] anArray;
int i = 0;
int size = 10;
anArray = new int[size];

// initialize array
for(i=0; i<size; i++) {
anArray[i] = i*100;
}

for(i=0; i<size; i++) {
System.out.println("Element at index " + i + ": " + anArray[i]);
}
}
}
dannyboi is offline   Reply With Quote
Old 07-28-2012, 11:43 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Works for me.
In the future please wrap your code in [code][/code] or [php][/php] tags to preserve formatting.
Fou-Lu is offline   Reply With Quote
Old 07-29-2012, 09:39 AM   PM User | #3
greeninho
New Coder

 
Join Date: Dec 2011
Location: abuja
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
greeninho is an unknown quantity at this point
ordinarily, this code should work. But you have an unnecessary for-loop statement. Debug the second for-loop statement, then copy the output statement and paste inside the first for-loop statement. Try it. Hope you got it?
greeninho is offline   Reply With Quote
Reply

Bookmarks

Tags
java, java programming

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:38 AM.


Advertisement
Log in to turn off these ads.