Insert data, convert Int to String

Asked

Viewed 77 times

0

inserir a descrição da imagem aqui

The error happens pq in the Funcio_dao() class, the variables with error are declared as INT, I can’t remember which code to correct conversion.

1 answer

0


The conversion can be done as below:

 Integer.valueOf(Txt_Email.getText())

If the value is of primitive type Voce can do:

  Integer.valueOf(Txt_Email.getText()).intValue()

In your case I’d be:

objFunc_Enc.setEmail(Integer.valueOf(Txt_Email.getText()).intValue())

A hint in Java uses some patterns for identifiers (class name, attributes, and methods), for variable and attribute names using letters in the camelcase pattern with the initial letter lowercase.

  • Marciano, I’m still starting in java, I understand the theory, but can you show me how the full syntax would look? thanks for your attention.

  • Hello Gustavo, what you don’t understand?

  • For example: objFunc_Enc.setEmail(Txt_email.gettext(); where do I have to insert: Integer.valueOf(Txt_email.gettext())? I thought of a syntax like this: objFunc_Enc.setEmail.Integer.valueOf(Txt_email.gettext()); , but it was an error, so I think I’m wrong.

  • I updated the answer, please check.

  • it worked, it worked: objFunc_Enc.setEmail(Integer.parseint(Txt_email.gettext()); THANKS!!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.