Results 1 to 3 of 3
  1. #1
    Swane is offline Member
    Join Date
    Sep 2014
    Posts
    5
    Rep Power
    0

    Default random cannot be resolved

    so i am pretty new to java and i am learning something at java in my school and i was given the assignment to make script so that is will fill an array with random numbers using "recyclable" parts.
    so my script is:
    import java.util.*;
    class eser_ha_dibrot_4
    {
    public static void main(String[] args)
    {
    int []a=new int[10];
    fill(a);
    }
    public static void fill(int []a)
    {
    int up=99;
    int down=10;
    for(int i=0;i<a.length;i++)
    a[i]=down+(int)(Math.random*(up-down+1));
    }
    }
    and i get this error: "random cannot be resolved or is not a field"
    what to do?

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: random cannot be resolved

    Math.random -> Math.random()

    The error is telling you "random is not a field". It is not lying, it is a method!
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    Swane is offline Member
    Join Date
    Sep 2014
    Posts
    5
    Rep Power
    0

    Default Re: random cannot be resolved

    ooooooow thnx lol i made such a silly mistake

Similar Threads

  1. Replies: 0
    Last Post: 01-23-2012, 09:12 AM
  2. canvasObject cannot be resolved.
    By falconfetus8 in forum New To Java
    Replies: 10
    Last Post: 12-30-2011, 11:42 PM
  3. Replies: 14
    Last Post: 10-19-2009, 10:57 AM
  4. Replies: 8
    Last Post: 04-19-2009, 05:50 PM
  5. random numbers without random class`
    By carlos123 in forum New To Java
    Replies: 4
    Last Post: 01-17-2008, 10:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •