Q: Syntax error: java doesn't recognize a method I have imported all classes.
Here at sendMessage i recieve the error: void is an invalid type of the variable sendMessage.
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    public void sendMessage(View view){

    }
}


A: You must not declare a method within another method. Close the curly bracket of onCreate before starting to declare the sendMessage method.
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}// close onCreate method first

public void sendMessage(View view){
}

A java class is structured like this:


*

*package


*

*class


*

*field

*method


*

*no method declaration allowed within another method


*(inner classes)



