Jump to content

Java Validation - Unsure Of Correct Type To Be Using


Recommended Posts

    public void setType(char aType) throws DishException
if(aType.length() == 0)
throw new DishException ("A dish type must be entered");

type = aType;

ERROR: object type required, but char found.[/CODE]

I am using jbuilder 3 and I am aware I am using the wrong validation but since I'm unsure what is the correct method to use for char type validation I'm here to see what help I can get.

Since I've not covered char before this is new too me.

This is the only validation error I am having others are intiger and string without any errors. I have to keep it as character and not change it.

Thanks in advance.

Link to comment
Share on other sites

char is a Java primitive type, and thus not an actual object. If you where to change it to be a String or some thing that error would go away, and, in fact, String is possibly the type it's meant to be since the length method is used. Admittedly it could be nearly any object, but String length method has meaning (String is an object btw).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...