0

I know that I can use Object as the parameter type , but then I have to cast to the class I want.

My question is: Can I do something like that

public void doSomething( <T extends Person> person ) { Student student = person ; } 

like what we can achieve with return type in java

public <T extends Person> T findPerson() { ;;;;;} Student student = findPerson(1) ; 

English is not my native language, so sorry if the question is not clear enough

1 Answer 1

1

You can use it like

public <T extends SomeClass> void doSomething(T item){ //Do something item.number = 4; } 

Where:

class SomeClass{ public int number; } 

Check this article, I hope it will help you.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.