3 Replies - 171 Views - Last Post: 05 March 2012 - 01:39 PM Rate Topic: -----

#1 IntensiveYourEfforts  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 20
  • Joined: 21-March 11

working with Random objects Question

Posted 05 March 2012 - 01:33 PM

Hey guys, I'm getting this error: Randoms.java:17: error: ';' expected

I'm not exactly sure what is causing it.
import java.util.Random;

public class Randoms
{
	public static void main( String [] args )
	{
		Random r = new Random();
		
		
		Random rr = new Random();
		
		
		If ( r.nextInt(100) > rr.nextInt(100) );
			System.out.println(rr);
		
		Else
			System.out.println(r);
			
	}
}
		
		




Any ideas?

Is This A Good Question/Topic? 0
  • +

Replies To: working with Random objects Question

#2 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1057
  • View blog
  • Posts: 2,260
  • Joined: 30-January 11

Re: working with Random objects Question

Posted 05 March 2012 - 01:36 PM

You have a semicolon at the end of this line -

If ( r.nextInt(100) > rr.nextInt(100) );

Plus Java is case sensitive - If and Else if different to if and else (the latter begin correct)
Was This Post Helpful? 1
  • +
  • -

#3 IntensiveYourEfforts  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 20
  • Joined: 21-March 11

Re: working with Random objects Question

Posted 05 March 2012 - 01:37 PM

Thank you, rep given
Was This Post Helpful? 0
  • +
  • -

#4 c.vikramnarayan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 16-May 08

Re: working with Random objects Question

Posted 05 March 2012 - 01:39 PM

Hi seems you have misplaced a ; after the if statement. Placing a ; after if statement ends the if, so the compiler cannot find an equivalent if for the else statement. Remove the ; after the if statement and try again.

Thanks,
Vikram
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1