Thread: Class, interface, or enum expected

Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1 Class, interface, or enum expected 
    pillowfight
    Guest
    This is my error:

    Code:
    Cats.java:36: class, interface, or enum expected
    }
    ^
    1 error
    Finished!
    Press any key to continue . . .
    This is my code:
    Code:
    public class Cats {
    
    public int GetCatNpc(int catitem) {
    if(catitem == 1555) return 761;
    if(catitem == 1556) return 762;
    if(catitem == 1557) return 763;
    if(catitem == 1558) return 764;
    if(catitem == 1559) return 765;
    if(catitem == 1560) return 766;
    if(catitem == 1561) return 768;
    if(catitem == 1562) return 769;
    if(catitem == 1563) return 770;
    if(catitem == 1564) return 771;
    if(catitem == 1565) return 772;
    if(catitem == 1566) return 773;
    if(catitem == 7585) return 3507;
    return 0;
    }
    public int GetCatItem(int catnpc) {
    if(catnpc == 761) return 1555;
    if(catnpc == 762) return 1556;
    if(catnpc == 763) return 1557;
    if(catnpc == 764) return 1558;
    if(catnpc == 765) return 1559;
    if(catnpc == 766) return 1560;
    if(catnpc == 768) return 1561;
    if(catnpc == 769) return 1562;
    if(catnpc == 770) return 1563;
    if(catnpc == 771) return 1564;
    if(catnpc == 772) return 1565;
    if(catnpc == 773) return 1566;
    if(catnpc == 3507) return 7585;
    return 0;
    }
    Help?
    Reply With Quote  
     

  2. #2  
    EndoSmoke
    Guest
    Use conventions.

    Code:
    public class Cats {
    
    	public int GetCatNpc(int catitem) {
    		if(catitem == 1555) {
    			return 761;
    		}
    		if(catitem == 1556) {
    			return 762;
    		}
    		if(catitem == 1557) {
    			return 763;
    		}
    		if(catitem == 1558) {
    			return 764;
    		}
    		if(catitem == 1559) {
    			return 765;
    		}
    		if(catitem == 1560) {
    			return 766;
    		}
    		if(catitem == 1561) {
    			return 768;
    		}
    		if(catitem == 1562) {
    			return 769;
    		}
    		if(catitem == 1563) {
    			return 770;
    		}
    		if(catitem == 1564) {
    			return 771;
    		}
    		if(catitem == 1565) {
    			return 772;
    		}
    		if(catitem == 1566) {
    			return 773;
    		}
    		if(catitem == 7585) {
    			return 3507;
    		}
    		return 0;
    	}
    	public int GetCatItem(int catnpc) {
    		if(catnpc == 761) {
    			return 1555;
    		}
    		if(catnpc == 762) {
    			return 1556;
    		}
    		if(catnpc == 763) {
    			return 1557;
    		}
    		if(catnpc == 764) {
    			return 1558;
    		}
    		if(catnpc == 765) {
    			return 1559;
    		}
    		if(catnpc == 766) {
    			return 1560;
    		}
    		if(catnpc == 768) {
    			return 1561;
    		}
    		if(catnpc == 769) {
    			return 1562;
    		}
    		if(catnpc == 770) {
    			return 1563;
    		}
    		if(catnpc == 771) {
    			return 1564;
    		}
    		if(catnpc == 772) {
     			return 1565;
    		}
    		if(catnpc == 773) {
    			return 1566;
    		}
    		if(catnpc == 3507) {
     			return 7585;
    		}
    		return 0;
    	}
    }
    You needed a bracket to end your Class.
    Reply With Quote  
     

  3. #3  
    Banned

    Join Date
    Jul 2008
    Posts
    2,056
    Thanks given
    26
    Thanks received
    98
    Rep Power
    0
    What he said.

    When is says class, interface or enum expected, it is telling you that it needs one of those things. in this case, you needed an extra enum (another name for a })

    So just add one and the compiler will be happy.
    Reply With Quote  
     

  4. #4  
     

    Vastiko's Avatar
    Join Date
    Dec 2006
    Posts
    5,700
    Thanks given
    300
    Thanks received
    663
    Rep Power
    5000
    Quote Originally Posted by Jonny J View Post
    What he said.

    When is says class, interface or enum expected, it is telling you that it needs one of those things. in this case, you needed an extra enum (another name for a })

    So just add one and the compiler will be happy.
    enum is not a }

    } is a bracket, not a brace or any shit like that.

    an enum is:

    public enum OpenEyed{
    \t OPEN,
    \t CLOSED
    }

    referenced:
    if(player.getEyes().equals(OpenEyed.OPEN)) {
    \t DO Action
    }

    ?

    And as to the error its just saying it cannot complete the class so it doesn't know whats going on
    Reply With Quote  
     

  5. #5  
    Banned

    Join Date
    Jul 2008
    Posts
    2,056
    Thanks given
    26
    Thanks received
    98
    Rep Power
    0
    I stand corrected

    Reply With Quote  
     

  6. #6  
    Banned

    Join Date
    Jul 2008
    Age
    28
    Posts
    5,827
    Thanks given
    1,301
    Thanks received
    197
    Rep Power
    0
    Fuck?
    Class or enum expected because he put one to many closing brackets.
    Reply With Quote  
     

  7. #7  
     

    Vastiko's Avatar
    Join Date
    Dec 2006
    Posts
    5,700
    Thanks given
    300
    Thanks received
    663
    Rep Power
    5000
    Quote Originally Posted by Java` View Post
    Fuck?
    Class or enum expected because he put one to many closing brackets.
    One to less

    One too many would result in identifier expected I think
    Reply With Quote  
     

  8. #8  
    Community Veteran

    Dexter Morgan's Avatar
    Join Date
    Nov 2008
    Age
    28
    Posts
    4,419
    Thanks given
    1,184
    Thanks received
    757
    Rep Power
    3098
    Code:
    	/**
    	 * Class Cats
    	 *
    	 * Version 1.0
    	 *
    	 * @author pillowfight
    	 *
    	 * 14:48 05/08/2009
    	 *
    	 */
    
    public class Cats {
    
    	/**
    	 * Method getCatNpc(int)
    	 *
    	 *@param catItem - gets/diplays cat's item.
    	 *
    	 */
    
    	public int getCatNpc(int catItem) {
    		switch(catItem) {
    			case 1555: return 761;
    			case 1556: return 762;
    			case 1557: return 763;
    			case 1558: return 764;
    			case 1559: return 765;
    			case 1560: return 766;
    			case 1561: return 768;
    			case 1562: return 769;
    			case 1563: return 770;
    			case 1564: return 771;
    			case 1565: return 772;
    			case 1566: return 773;
    			case 7585: return 3507;
    		default: return 0;
    		}
    	}
    
    
    	/**
    	 * Method gettCatItem(int)
    	 *
    	 *@param catNpc - gets/diplays a cat npc.
    	 *
    	 */
    
    	public int gettCatItem(int catNpc) {
    		switch(catNpc) {
    			case 761: return 1555;
    			case 762: return 1556;
    			case 763: return 1557;
    			case 764: return 1558;
    			case 765: return 1559;
    			case 766: return 1560;
    			case 768: return 1561;
    			case 769: return 1562;
    			case 770: return 1563;
    			case 771: return 1564;
    			case 772: return 1565;
    			case 773: return 1566;
    			case 3507: return 7585;
    		default: return 0;
    		}
    	}
    }
    Use switch statement, conventions and and those /* */ things; forgot what they're called
    Reply With Quote  
     

  9. #9  
    pillowfight
    Guest
    I used the on in the last reply and get this:

    Code:
    client.java:17067: variable droppedItem might not have been initialized
    if(droppedItem == 1560)
       ^
    client.java:17071: variable slot might not have been initialized
    deleteItem(droppedItem, slot, playerItemsN[slot]);
                            ^
    client.java:17077: variable slot might not have been initialized
    deleteItem(droppedItem, slot, playerItemsN[slot]);
                            ^
    client.java:17083: variable slot might not have been initialized
    deleteItem(droppedItem, slot, playerItemsN[slot]);
                            ^
    client.java:17089: variable slot might not have been initialized
    deleteItem(droppedItem, slot, playerItemsN[slot]);
                            ^
    client.java:17095: variable slot might not have been initialized
    deleteItem(droppedItem, slot, playerItemsN[slot]);
                            ^
    client.java:17101: variable slot might not have been initialized
    deleteItem(droppedItem, slot, playerItemsN[slot]);
                            ^
    client.java:17107: variable slot might not have been initialized
    deleteItem(droppedItem, slot, playerItemsN[slot]);
                            ^
    client.java:17113: variable slot might not have been initialized
    deleteItem(droppedItem, slot, playerItemsN[slot]);
                            ^
    client.java:17119: variable slot might not have been initialized
    deleteItem(droppedItem, slot, playerItemsN[slot]);
                            ^
    client.java:17125: variable slot might not have been initialized
    deleteItem(droppedItem, slot, playerItemsN[slot]);
                            ^
    client.java:17131: variable slot might not have been initialized
    deleteItem(droppedItem, slot, playerItemsN[slot]);
                            ^
    client.java:17137: variable slot might not have been initialized
    deleteItem(droppedItem, slot, playerItemsN[slot]);
                            ^
    client.java:17143: variable slot might not have been initialized
    deleteItem(droppedItem, slot, playerItemsN[slot]);
                            ^
    Note: EconomyReset.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    14 errors
    Finished!
    Press any key to continue . . .
    Reply With Quote  
     

  10. #10  
    EndoSmoke
    Guest
    Quote Originally Posted by pillowfight View Post
    I used the on in the last reply and get this:

    Code:
    client.java:17067: variable droppedItem might not have been initialized
    if(droppedItem == 1560)
       ^
    client.java:17071: variable slot might not have been initialized
    deleteItem(droppedItem, slot, playerItemsN[slot]);
                            ^
    client.java:17077: variable slot might not have been initialized
    deleteItem(droppedItem, slot, playerItemsN[slot]);
                            ^
    client.java:17083: variable slot might not have been initialized
    deleteItem(droppedItem, slot, playerItemsN[slot]);
                            ^
    client.java:17089: variable slot might not have been initialized
    deleteItem(droppedItem, slot, playerItemsN[slot]);
                            ^
    client.java:17095: variable slot might not have been initialized
    deleteItem(droppedItem, slot, playerItemsN[slot]);
                            ^
    client.java:17101: variable slot might not have been initialized
    deleteItem(droppedItem, slot, playerItemsN[slot]);
                            ^
    client.java:17107: variable slot might not have been initialized
    deleteItem(droppedItem, slot, playerItemsN[slot]);
                            ^
    client.java:17113: variable slot might not have been initialized
    deleteItem(droppedItem, slot, playerItemsN[slot]);
                            ^
    client.java:17119: variable slot might not have been initialized
    deleteItem(droppedItem, slot, playerItemsN[slot]);
                            ^
    client.java:17125: variable slot might not have been initialized
    deleteItem(droppedItem, slot, playerItemsN[slot]);
                            ^
    client.java:17131: variable slot might not have been initialized
    deleteItem(droppedItem, slot, playerItemsN[slot]);
                            ^
    client.java:17137: variable slot might not have been initialized
    deleteItem(droppedItem, slot, playerItemsN[slot]);
                            ^
    client.java:17143: variable slot might not have been initialized
    deleteItem(droppedItem, slot, playerItemsN[slot]);
                            ^
    Note: EconomyReset.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    14 errors
    Finished!
    Press any key to continue . . .
    Because it's wrong.

    Quote Originally Posted by EndoSmoke View Post
    Use conventions.

    Code:
    public class Cats {
    
    	public int GetCatNpc(int catitem) {
    		if(catitem == 1555) {
    			return 761;
    		}
    		if(catitem == 1556) {
    			return 762;
    		}
    		if(catitem == 1557) {
    			return 763;
    		}
    		if(catitem == 1558) {
    			return 764;
    		}
    		if(catitem == 1559) {
    			return 765;
    		}
    		if(catitem == 1560) {
    			return 766;
    		}
    		if(catitem == 1561) {
    			return 768;
    		}
    		if(catitem == 1562) {
    			return 769;
    		}
    		if(catitem == 1563) {
    			return 770;
    		}
    		if(catitem == 1564) {
    			return 771;
    		}
    		if(catitem == 1565) {
    			return 772;
    		}
    		if(catitem == 1566) {
    			return 773;
    		}
    		if(catitem == 7585) {
    			return 3507;
    		}
    		return 0;
    	}
    	public int GetCatItem(int catnpc) {
    		if(catnpc == 761) {
    			return 1555;
    		}
    		if(catnpc == 762) {
    			return 1556;
    		}
    		if(catnpc == 763) {
    			return 1557;
    		}
    		if(catnpc == 764) {
    			return 1558;
    		}
    		if(catnpc == 765) {
    			return 1559;
    		}
    		if(catnpc == 766) {
    			return 1560;
    		}
    		if(catnpc == 768) {
    			return 1561;
    		}
    		if(catnpc == 769) {
    			return 1562;
    		}
    		if(catnpc == 770) {
    			return 1563;
    		}
    		if(catnpc == 771) {
    			return 1564;
    		}
    		if(catnpc == 772) {
     			return 1565;
    		}
    		if(catnpc == 773) {
    			return 1566;
    		}
    		if(catnpc == 3507) {
     			return 7585;
    		}
    		return 0;
    	}
    }
    You needed a bracket to end your Class.

    Quote Originally Posted by L M A O View Post
    Use switch statement, conventions and and those /* */ things; forgot what they're called
    They're called comments.
    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

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