Results 1 to 5 of 5
  1. #1
    janedoe is offline Member
    Join Date
    Sep 2015
    Posts
    15
    Rep Power
    0

    Default extraction problem

    hi everyone,
    So I'm trying to extract an Id number (int)
    and store it in a string variable.
    but I keep getting the error " int cannot be dereferenced".
    why does that happen ? and how can I extract the Id ?

    to see the code please view reply #3


    thanks in advance.
    Last edited by janedoe; 09-18-2015 at 10:50 AM.

  2. #2
    trcooke is offline Tim Cooke
    Join Date
    Jul 2014
    Location
    Belfast
    Posts
    101
    Rep Power
    0

    Default Re: extraction problem

    Hard to say without seeing your code. But to get "int cannot be dereferenced" I expect you're doing something like this:
    Java Code:
    int item = 5;
    int itemId = item.getId();
    "dereference" can be interpreted as "call a method on". So you're trying to call a method on a primitive type, int, which is an error.

  3. #3
    janedoe is offline Member
    Join Date
    Sep 2015
    Posts
    15
    Rep Power
    0

    Default Re: extraction problem

    Quote Originally Posted by trcooke View Post
    Hard to say without seeing your code. But to get "int cannot be dereferenced" I expect you're doing something like this:
    Java Code:
    int item = 5;
    int itemId = item.getId();
    "dereference" can be interpreted as "call a method on". So you're trying to call a method on a primitive type, int, which is an error.


    here's the code
    Java Code:
    29  System.out.println("Enter student1's ID");
    30  int student1Id = key.nextInt();
    
    
    63  String student1Email = student1Id.substring(0).concat(domain.toUpperCase());
    
    
    37 System.out.print(student1Email);
    Last edited by janedoe; 09-18-2015 at 10:51 AM.

  4. #4
    trcooke is offline Tim Cooke
    Join Date
    Jul 2014
    Location
    Belfast
    Posts
    101
    Rep Power
    0

    Default Re: extraction problem

    Java Code:
    student1Id.substring(0)
    student1Id is an int.

  5. #5
    janedoe is offline Member
    Join Date
    Sep 2015
    Posts
    15
    Rep Power
    0

Similar Threads

  1. Keyphrase extraction
    By rohini in forum New To Java
    Replies: 1
    Last Post: 02-21-2015, 10:37 AM
  2. Extraction of Paragraphs in PDF-Document
    By Harald Groh in forum Advanced Java
    Replies: 0
    Last Post: 12-20-2013, 08:52 AM
  3. sub query extraction
    By mkarthik90 in forum Advanced Java
    Replies: 18
    Last Post: 02-13-2012, 03:00 PM
  4. green channel extraction
    By sarah49 in forum Java 2D
    Replies: 1
    Last Post: 01-27-2012, 11:14 AM
  5. web extraction
    By murali in forum Networking
    Replies: 3
    Last Post: 12-13-2008, 07:10 AM

Posting Permissions

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