Need some help with very basic code

Hello kind human,

I just started with Java in Android Studio and I’m just an hour in (no experience with coding). Im folowing this YouTube guide posted under the same name as this website, so I guess this is the place to be. Here is the link of the video with the time stamp:

I am getting 2 errors on this part:

  1. error: expected
    Public void onBtnClick (View view) {

  2. error: invalid method declaration; return type required
    Public void onBtnClick (View view) {
    Ill post my code below but I dont see anything that differs with the tutorial. I am running on Android 30 and the guide is on Android 29, thats the only difference I can think of.

Thanks a lot for reading this / helping me out getting started!

package com.example.helloworld2;


import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

public class MainActivity<Public> extends AppCompatActivity {

    protected void onCreate(Bundle savedInstanceState) {


        Public void onBtnClick (View view)  {
        TextView txtHello = findViewById( ;



I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

Right, sorry! Will do in the future, thanks for showing me.

Test this is not code but OK testtest

Capitalization matters.

Jeez lol, thanks it works now. Made myself feel dumb :smiley:

Yep. We’ve all made that mistake once or two million times.

1 Like