Why cannot we use static keyword inside a method in java?

How to declare a boolean and use a method JAVA help!?

  • Hi, I want to know how do i declare a field as a boolean type in the class and set it to "false" in the constructor... also, for a method, how would i change this value from 'true' to 'false' please help, im new to java..thank you in advance!

  • Answer:

    class BooleanTest { boolean isActive; public BooleanTest() { isActive = false; } // this will flip a boolean like a light switch public void switch() { isActive = !isActive; } public void setBoolean( boolean b ) { isActive = b; }

Samantha at Yahoo! Answers Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.