Printing java Boolean attributes

Asked

Viewed 906 times

-1

Good morning! I’m starting now in java and I have the following question: "Why doesn’t the Boolean Tuition attribute appear for me to display the reported result?" Follow below the image of the options that appear when I press CTRL+Spacebar.

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

  • Where this Student class is being declared?

  • If you are using the IDE to generate the code for the Student class, it is quite possible that the method name was generated as isMensality().

  • @Paulor.F.Amorim didn’t understand your question, but I just created the Student class and used it in main.

  • I wanted to see the file Aluno.java that appears next door

  • I entered in the question, the print of the Student class.

  • Preferably put the code instead of image, it makes it easier for those who are helping you.

Show 1 more comment

2 answers

1

In situations like this, you should go to the class and check if the method you want has been declared.

When Intellisense does not show the method/attribute, it means either the method/attribute does not exist or the class that is trying to access it is not allowed to do so. For example, the method could be like private, in this case, even if the method existed you also would not be able to see it by Intellisense.

As already mentioned in the answer /a/278954/7521, if you generated the code from the IDE, the method is probably named isMensalidade(). Ides usually insert code following the default language, in the case of Java, boolean attributes follow this standard of access methods:

private boolean hidden;

public void setHidden(boolean hidden) {
    this.hidden = hidden;
}

public boolean isHidden() {
    return this.hidden;
}

0


If you used the genereate get and set of the eclipse it puts attributes of type Boolean as isMensalidade()

  • Actually, as I had used generate getters ans eclipse setters he put the attribute as isMensality. I switched to getMensalidade and it worked correctly. Thanks for the help.

Browser other questions tagged

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