Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 9th, 2007, 07:10 AM
ganga_ln ganga_ln is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2007
Posts: 1 ganga_ln User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 55 sec
Reputation Power: 0
Lottery Program

I am soo stuck trying to write a lottery program which allows the user check their numbers against winning numbers. Can anybody helppp pleasee, i cant get my head around arrays.

Reply With Quote
  #2  
Old May 12th, 2007, 04:15 PM
daniel_g daniel_g is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 60 daniel_g User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 h 3 m 50 sec
Reputation Power: 3
Can you post your code and show us where you are stuck? It's hard to help if we don't know what you need help with.

Here is an example on how you make arrays:
Code:
int[] myArray = new int{1,2,3,4,5};

// 'int[]' specifies the type of data you want on the array
// 'myArray' is the name you give to your array
// 'new int' creates the object
// '{1,2,3,4,5}' are the elements in the array, in this case there are five


An alternate way to create the same array is:
Code:
int[] myArray2;
myArray2 = new int[5];
myArray2[0] = 1;
myArray2[1] = 2;
myArray2[2] = 3;
myArray2[3] = 4;
myArray2[4] = 5;

// 'int' and 'myArray2' are the same as before
// 'new int[5]' creates the array with size five
// 'myArray[y] = x' adds x number to the corresponding array position
// Note that the array index starts from 0.


I guess in your program you will be comparing numbers from 2 arrays or something, so if you want to compare specific elements on two arrays, you do something like:
Code:
if(myArray[0] == myArray2[0]){
    System.out.println("match");
}
else
    System.out.println("No match");

To compare all the items, you would use loops.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > Lottery Program


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT