DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Posts
    1

    Random Number Generator

    Im trying to make a random number generator for 8 shapes,and im have a little trouble at da moment with my coding.

    so far my function looks like this:


    public void random(){
    for(int i =1;i <8; i++){
    int n1 = (int) (Math.Random() * number);
    int n2 = (int) (Math.Random() * number);
    Shape temp = stack[n1];
    stack[n1] = stack[n2];
    stack[n2] = temp;
    }
    }
    }


    it wont seem to compile,so do i have to declare my n1 variables ? and also stack? IF i want to call the random function,how do i call it?

  2. #2
    Join Date
    Feb 2004
    Posts
    11
    The random method in Math is lower case. This sort of problem can be easily solved by looking up the searchable documentation online at:
    http://java.sun.com/j2se/1.4.2/search.html

    Try to get accustomed to using it. You'll find your answer much faster than you will through a message board.

    -Ernest

  3. #3
    Join Date
    Jan 2004
    Posts
    20
    If you compile a Java file and get a "connot resolve symbol" error, check all the spellings & cases are consistent (on that particular line number reported as containing the error) with what they should be, then check you've imported the correct classes/packages for what you have in your code.

    Cheers, DaveMark

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links