Results 1 to 2 of 2
  1. #1
    bdl1127 is offline Member
    Join Date
    Jan 2012
    Posts
    26
    Rep Power
    0

    Default Why am i getting this error in my method?

    Im getting a "Cannot invoke toString() on the primitive type int" error in the method toString(). I have tried changing the syntax and nothing looks wrong...any insight?

    public class Point {

    private int x;
    private int y;

    public Point(){
    }

    public Point(int x, int y) {
    this.x = x;
    this.y = y;
    }

    public void move(int x, int y) {
    move(x,y);
    }

    public void reposition(int x, int y) {

    }

    public String toString() {
    x.toString();
    y.toString();
    }

    }

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    6

    Default Re: Why am i getting this error in my method?

    1) you can`t call methods on primitive types?!
    2) the toString method must return a String!
    3) maybe you are looking for String.valueOf(...)
    4) check your move method :D

Similar Threads

  1. Method- error?
    By katiebear128 in forum New To Java
    Replies: 7
    Last Post: 10-16-2011, 04:01 PM
  2. Runtime error in a method
    By Pojahn_M in forum New To Java
    Replies: 8
    Last Post: 08-02-2011, 05:23 AM
  3. what does this error method mean?
    By berkeley in forum New To Java
    Replies: 1
    Last Post: 06-03-2010, 12:19 PM
  4. No Such Method Error - simple
    By n00b in forum New To Java
    Replies: 9
    Last Post: 05-04-2010, 05:05 PM
  5. Replies: 1
    Last Post: 02-10-2009, 11:03 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
  •