2 Replies - 746 Views - Last Post: 26 July 2019 - 01:36 AM Rate Topic: -----

#1 GingerSnacks   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 23-July 19

Int cannot be dereferenced

Posted 25 July 2019 - 05:03 PM

Hello all, having issue with the code below. Trying to get a phone-number to randomly generate on the second part and not to have the numbers 8 or 9 in the first three parts of the first number group:

import java.util.Random;

public class RandomPhone
{
public static void main(String [] args)
{
	Random random= new Random();

int phonenum1,phonenum2,phonenum3, full;

phonenum1.useDelimiter("8","9");

if(phonenum2>655)
{
	System.out.println("Sorry, greater than 655 try again");
}
full=phonenum1+phonenum2+phonenum3;

int ran=random.nextInt(655);


System.out.println("The full number is"+full);
}
}


The printstack error is this:

RandomPhone.java:11: error: int cannot be dereferenced
phonenum1.useDelimiter("8","9");

Is This A Good Question/Topic? 0
  • +

Replies To: Int cannot be dereferenced

#2 NormR   User is offline

  • D.I.C Lover
  • member icon

Reputation: 780
  • View blog
  • Posts: 5,858
  • Joined: 25-December 13

Re: Int cannot be dereferenced

Posted 25 July 2019 - 05:26 PM

Quote

RandomPhone.java:11: error: int cannot be dereferenced
phonenum1.useDelimiter("8","9");

There are no methods for a primitive variable. int is a primitive.

What class is the useDelimiter method from?
Where is there an instance of the class that support a call to that method?
Was This Post Helpful? 0
  • +
  • -

#3 g00se   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3639
  • View blog
  • Posts: 16,718
  • Joined: 20-September 08

Re: Int cannot be dereferenced

Posted 26 July 2019 - 01:36 AM

You're mixing up int with Scanner (which you've not even declared or used yet)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1