What could be wrong here and how to deal with it? Wrong point and bracket? How?

Closed due to the fact that off-topic participants zRrr , Streletz , Alexey Shimansky , user194374, cheops 24 Jun '16 at 19:03 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - zRrr, Streletz, Alexey Shimansky, Community Spirit, cheops
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • Show what's in your MainClass class? - Werder
  • Please read books on java syntax, the question is more than basic. - Victor

1 answer 1

You are trying to call class methods in the middle of declarations of another class. This is not how it works. It's not clear what's in your MainClass class, but nevertheless, I suppose it should look something like this.

Your MainClass

class MainClass{ String myLittleString; public String getMyLittleString() { return myLittleString; } public void setMyLittleString(String myLittleString) { this.myLittleString = myLittleString; } } 

Class with public static void main function

 public class Main { public static void main(String[] args) { MainClass Nechto = new MainClass(); Nechto.setMyLittleString("ЗАРАБОТАЛО"); } }