I'm getting error in Android Studio on second "cannot resolve symbol second" how to fix it so that it loops from 358 to 331 in this example?
package com.example.myapp;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;

import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.YouTubePlayer;
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.listeners.AbstractYouTubePlayerListener;
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView;

public class FingerStretching extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_finger_stretching);

        YouTubePlayerView youTubePlayerView = findViewById(R.id.youtube_player_view);
        getLifecycle().addObserver(youTubePlayerView);

        youTubePlayerView.addYouTubePlayerListener(new AbstractYouTubePlayerListener() {
            String videoId = "mSZWSQSSEjE";
            @Override
            public void onReady(@NonNull YouTubePlayer youTubePlayer) {
                youTubePlayer.loadVideo(videoId, 331);
            }
            
            public void onCurrentSecond(@NonNull YouTubePlayer youTubePlayer) {
                if(second == 358) youTubePlayer.seekTo(331);
            }
        });



    }
}

tried creating local variable second

How to repeat video with start and end time in Android Studio?
According to the source code, the signature of onCurrentSecond is
override fun onCurrentSecond(youTubePlayer: YouTubePlayer, second: Float)

You are not overriding it. It should be
@Override
public void onCurrentSecond(@NonNull YouTubePlayer youTubePlayer, float second) {
    if(second >= 358) youTubePlayer.seekTo(331);
}

Such kind of error is easily avoidable if you make use of the auto complete feature in the IDE. Typing onC within the AbstractYouTubePlayerListener should give you auto complete option for onCurrentSecond, selecting it should automatically write the override function for you with correct signature.
