Skip to content

Instantly share code, notes, and snippets.

@Rohit-554
Created March 25, 2023 18:43
Show Gist options
  • Select an option

  • Save Rohit-554/3ed5c74b829f4a41d68b539f2cac3fc5 to your computer and use it in GitHub Desktop.

Select an option

Save Rohit-554/3ed5c74b829f4a41d68b539f2cac3fc5 to your computer and use it in GitHub Desktop.
public class GenricMethod {
public void printList(String []s){
for(int i=0;i<s.length;i++){
System.out.println(s[i]);
}
}
public <T> void printlist(T []s){
for( T x :s){
System.out.println(x);
}
}
public static void main(String[] args) {
GenricMethod ob1 = new GenricMethod();
String s[] = new String[]{"This","Is","Something"};
ob1.printList(s);
// Integer a[] = new Integer[]{1,2,3};
// ob1.printlist(a);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment