Results 1 to 3 of 3
  1. #1
    paccerz is offline Member
    Join Date
    Aug 2011
    Rep Power

    Default Invalid method declaration; return type required? Please Help!

    I am currenltly making a modification on a game and i have ran into this error please may u guys tell me what is wrong with my code?

    package net.minecraft.src;

    public class ItemPorkScratching extends Item
    private int healAmount;

    public ItemScratching(int i) {
    super (i);
    maxStackSize = 1;
    healAmount = 1.5;

    public int getHealAmount()
    return healAmount;

    public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
    return itemstack;

    It may be something really obvious but i am new to java so please help :)
    Last edited by paccerz; 08-23-2011 at 09:33 PM.

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Richmond, Virginia
    Blog Entries
    Rep Power


    The constructor name must be identical to the class name, otherwise the compiler thinks it's a method, and the form of a cosntructor is invalid for a method declaration.

  3. #3
    Iron Lion is offline Senior Member
    Join Date
    Nov 2010
    Rep Power


    Why are you declaring healAmount as an int and then assigning 1.5 to it?

Similar Threads

  1. JavaBean - invalid method declaration and return type required
    By jprog in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 05-07-2011, 07:13 PM
  2. Invalid Method Declaration; Return Type Required
    By bremzb in forum AWT / Swing
    Replies: 3
    Last Post: 05-05-2011, 11:12 PM
  3. Err: invalid method declaration; return type required
    By Die The Villain in forum New To Java
    Replies: 12
    Last Post: 04-15-2011, 01:44 AM
  4. invalid method declaration; return type required
    By XaviannNJ in forum JCreator
    Replies: 7
    Last Post: 11-25-2010, 02:59 PM
  5. Replies: 3
    Last Post: 06-05-2010, 09:05 PM

Tags for this Thread

Posting Permissions

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