Lost Password?

Go Back   CodeCall Programming Forum > Software Development > Java Help

Unregistered, Check out the Coder Battles in the Announcement and Game forums.

Java Help Java Help forum discussing all Java platforms - J2ME, J2SE and J2EE - as well as relevant standards, APIs and frameworks such as Swing, Servlets, JSPs, Applets, Struts, Spring, Hibernate, ANT, EJB, and other Java-related topics.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-14-2006, 09:38 PM
tim838 tim838 is offline
Newbie
 
Join Date: Oct 2006
Posts: 1
Credits: 0
Rep Power: 0
tim838 is on a distinguished road
Default Generate random points

Hi,
I'm new to programming and am using BlueJ. I'm trying to generate n random points with [x,y] co-ords each in the range (0,1).

double[] location = new double [n];
for (i=0;i<n;i++){
location[i]=Math.random();

is what i was thinking however this does not work since i is not defined properly. I'm a little confused, any help would be appreciated.

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 10-16-2006, 01:29 PM
Lop's Avatar   
Lop Lop is offline
Speaks fluent binary
 
Join Date: May 2006
Posts: 1,149
Credits: 112
Rep Power: 16
Lop will become famous soon enough
Default

you need

Code:
for (int i=0;i<n;i++)
to make this work.
__________________
Lop
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 10-16-2006, 06:59 PM
falco85 falco85 is offline
Programmer
 
Join Date: Apr 2006
Posts: 105
Credits: 2
Rep Power: 10
falco85 is on a distinguished road
Default

Or declare i before the for

int i = 0;
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Generating Random Numbers with PHP Paradine PHP Tutorials 4 08-27-2007 07:09 PM
Return random numbers without duplicates Paradine PHP Tutorials 0 08-26-2007 02:07 PM
Code:PHP Random Functions John PHP Tutorials 2 12-03-2006 10:04 AM
Store and Points System Jordan Announcements 9 08-28-2006 01:38 PM
I need to generate a random number in PHP dirkfirst PHP Forum 7 07-05-2006 09:58 PM


All times are GMT -5. The time now is 07:49 PM.

Contest Stats

Xav ........ 1333.07
MeTh0Dz|Reb0rn ........ 1055.7
John ........ 883.37
morefood2001 ........ 879.43
marwex89 ........ 869.98
WingedPanther ........ 851.68
Brandon W ........ 760.23
chili5 ........ 312.39
Steve.L ........ 247.05
dcs ........ 219.87

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 82%

Ads