Acessing tags in Java

I am making a game and need to identify if the player is touching an object or an AI.

My object (A box) is a trigger and adds ammo to the player, but when the AI touches the box it also adds ammo to the player. I am trying to use tags to tell what is touching the box. What i am currently using (That does NOT work) is this line of code
//
if(GameObject.FindWithTag == (“Player”)) {
"“Then my code”
}

//

I am new to java.

GameObject.FindWithTag() returns the first thing it finds in the scene which has the specified tag (which is passed as the parameter).

If you want to know if the thing that bumped into the trigger collider has a specific tag you need to use the “other” parameter passed into the OnTriggerEnter function by the physics engine

i.e.

if(other.tag == "Player")
{
//.. was the player so do player interaction stuff

Is this in java? I am getting an error saying “Unknown identifier: ‘other’.”

show us the whole method, other is the default argumeant in a OnTriggerEnter

Thank you all for the replies! I got it working after a few tries. Thanks!