Results 1 to 9 of 9

Thread: int arguments

  1. #1
    batousai is offline Member
    Join Date
    Jan 2013
    Posts
    4
    Rep Power
    0

    Default int arguments

    Hi

    i am really struggling with something which i think is very basic.

    i am trying to write a piece of code that will allow 2 objects to move into 2 different positions

    I will show you what the method looks like, then maybe you can tell me where i am going wrong

    public void moveToPosition (int a, int b)

    {
    object1.setPosition(a)
    object2.setPosition(b)
    }


    when i try having just (int a) and applying it to both variables the objects move into the same position, but i just can't figure out how to move them to different positions.

    thanks

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: int arguments

    What's wrong with the code you're showing us? Does it cause bad behavior? Does it not compile?

    Also, when posting code, don't highlight it with bold tags, [b] [/b]. Instead use code tags: [code] [/code] so that your code formatting is retained.

  3. #3
    batousai is offline Member
    Join Date
    Jan 2013
    Posts
    4
    Rep Power
    0

    Default Re: int arguments

    hi

    first of all i am using something called blueJ which is a training platform

    it compiles, but when i try to move the objects in the display i get an error

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

  5. #5
    batousai is offline Member
    Join Date
    Jan 2013
    Posts
    4
    Rep Power
    0

    Default Re: int arguments

    Sorry, i thought you would see something wrong with that method, i've only been learning over the past couple of weeks, so i finding this very difficult

    the error is: java.lang.NoSuchMethodError

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: int arguments

    What line causes this error to occur? Is it the two method calls inside of your method? If so, you need to know what the variable type of object1 and object2 are, and only call legal methods for those variables. Again, we're missing information here and can only help us as well as you let us.

  7. #7
    batousai is offline Member
    Join Date
    Jan 2013
    Posts
    4
    Rep Power
    0

    Default Re: int arguments

    java.lang.NoSuchMethodError:
    moving.moveToPosition(II)V
    in (Workspace:1)


    when i use 1 int value in the header it works, but when i use 2 int values, i get this error
    Last edited by batousai; 01-09-2013 at 05:59 AM.

  8. #8
    Sierra is offline AN21XX
    Join Date
    Mar 2012
    Location
    Munich
    Posts
    297
    Rep Power
    3

    Default Re: int arguments

    I am a little less perceptive than Fubarable... could you please post the whole code segment, that is at least the complete method/class and the complete error message...
    I like likes!

  9. #9
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,783
    Blog Entries
    7
    Rep Power
    21

    Default Re: int arguments

    Quote Originally Posted by batousai View Post
    java.lang.NoSuchMethodError:
    moving.moveToPosition(II)V
    in (Workspace:1)


    when i use 1 int value in the header it works, but when i use 2 int values, i get this error
    That must be a runtime error, because Javac (the compiler) never shows the signatures of methods in their internal form (II)V; it is trying to tell you that no method returning void (V), that takes two int parameters (II) exists. The method you showed us in your OP wasn't actual code which is very confusing. Always show us the actual code that is giving you problems and show the actual error messages as well.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. vm arguments
    By mharsijamel in forum NetBeans
    Replies: 4
    Last Post: 01-02-2012, 01:40 PM
  2. Arguments
    By maya700 in forum New To Java
    Replies: 12
    Last Post: 02-01-2011, 06:57 PM
  3. help with arguments
    By smilinglady in forum New To Java
    Replies: 33
    Last Post: 01-27-2011, 04:10 AM
  4. Replies: 8
    Last Post: 09-23-2010, 01:07 AM
  5. Passign arguments
    By ninjalord918 in forum AWT / Swing
    Replies: 4
    Last Post: 08-04-2010, 12:11 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
  •