8 Replies - 186 Views - Last Post: 30 January 2019 - 11:16 AM Rate Topic: -----

#1 lauraluna   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 30-January 19

why does it not work on eclipse?

Posted 30 January 2019 - 10:05 AM

public class randomnumber {

public static void main (String [] args) {
	int n = integer.parseInt(args [0]);
	int m = Integer.parseInt(args[1]);
	        
	random = (int) (Math.random() * (m - n + 1)+n);
	        
	System.out.println(random);
	    }
	}
:code:

This post has been edited by modi123_1: 30 January 2019 - 10:09 AM
Reason for edit:: In the future, please use the [code] tag button in the editor.

Is This A Good Question/Topic? 0
  • +

Replies To: why does it not work on eclipse?

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14852
  • View blog
  • Posts: 59,263
  • Joined: 12-June 08

Re: why does it not work on eclipse?

Posted 30 January 2019 - 10:09 AM

Doesn't work... how?

If there are errors the please copy/paste them here.

If it is not giving expected results then explain what you are inputting, what the output is, and what you expect it to be.
Was This Post Helpful? 0
  • +
  • -

#3 lauraluna   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 30-January 19

Re: why does it not work on eclipse?

Posted 30 January 2019 - 10:12 AM

I don't know why this code does not run but this is what they say

Exception in thread "main" java.lang.Error: Unresolved compilation problems:
integer cannot be resolved
random cannot be resolved to a variable
random cannot be resolved to a variable

at Randomnumber.main(Randomnumber.java:5)
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14852
  • View blog
  • Posts: 59,263
  • Joined: 12-June 08

Re: why does it not work on eclipse?

Posted 30 January 2019 - 10:23 AM

It says the compiler doesn't understand those lines. I would step back and ask yourself - "is Java case sensitive?". Fix accordingly.
Was This Post Helpful? 0
  • +
  • -

#5 lauraluna   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 30-January 19

Re: why does it not work on eclipse?

Posted 30 January 2019 - 10:24 AM

what I dont understand is that this code runs on nano but not on eclipse
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14852
  • View blog
  • Posts: 59,263
  • Joined: 12-June 08

Re: why does it not work on eclipse?

Posted 30 January 2019 - 10:29 AM

I don't know what 'nano' is, but there could be any number of issues.. copied wrong, compiler errors, compilers being more forgiving, etc.

Fix the out and out obvious errors and you should be good to go.
Was This Post Helpful? 0
  • +
  • -

#7 wseng92   User is offline

  • D.I.C Addict

Reputation: 37
  • View blog
  • Posts: 581
  • Joined: 23-September 15

Re: why does it not work on eclipse?

Posted 30 January 2019 - 10:46 AM

Quote

integer cannot be resolved
Should be Integer instead

Quote

random cannot be resolved to a variable
You are not declaring random.Declare it like how you declare variables n and m

This post has been edited by wseng92: 30 January 2019 - 10:48 AM

Was This Post Helpful? 0
  • +
  • -

#8 xclite   User is offline

  • I wrote you an code
  • member icon


Reputation: 1354
  • View blog
  • Posts: 4,179
  • Joined: 12-May 09

Re: why does it not work on eclipse?

Posted 30 January 2019 - 11:16 AM

View Postlauraluna, on 30 January 2019 - 12:24 PM, said:

what I dont understand is that this code runs on nano but not on eclipse

It doesn't run in nano, because nano is a text editor. It doesn't run code.
Was This Post Helpful? 0
  • +
  • -

#9 g00se   User is online

  • D.I.C Lover
  • member icon

Reputation: 3617
  • View blog
  • Posts: 16,595
  • Joined: 20-September 08

Re: why does it not work on eclipse?

Posted 30 January 2019 - 11:16 AM

Quote

what I dont understand is that this code runs on nano but not on eclipse

Nano is an editor, as is Eclipse (a glorified one). Code doesn't "run" on either. Code runs on a Java Virtual Machine. It won't run on the JVM because it must be compiled first and it doesn't compile. Where you've written it with nano, if it runs at all, then it's because it's different there and free of compilation errors

This post has been edited by g00se: 30 January 2019 - 11:17 AM
Reason for edit:: typo

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1