If you like the video, share it with your friends on these social sites:

 

Title: Intermediate Java Tutorial - 18 - Implementing a Generic Method

Added: Feb 28, 2010

Author: thenewboston

Duration: 4:57

Description:
How to use a generic method.

Related Videos:

Videos related to 'Intermediate Java Tutorial - 18 - Implementing a Generic Method'

Channel: Education

Tags: install  download  jdk  se  ee  java  development  kit  new  beginner  tutorials  eclipse  variables  if  while  loop  object  classes 



install  download  jdk  se  ee  java  development  kit  new  beginner  tutorials  eclipse  variables  if  while  loop  object  classes 

Youtube Comments: 41

macisejt Says:

Jan 7, 2011 - hey, thanks, you save me a lot of time :)

mufaPufaDha Says:

Jan 21, 2011 - cool, didnt know that one :)i was just typin one space, then select it with shift+leftArrow,then ctrl+space, arrowUp and enter, but syso is faster ;P

Mrjameslat Says:

Feb 21, 2011 - ha, T B

WuIzMe Says:

May 17, 2011 - bucky i could turn gay and kiss you right now... your vids are AWESOME THANKS!!!

hemagoku Says:

Aug 14, 2011 - i don't understand ,can u explain ?

saksepapirlim Says:

Aug 15, 2011 - @hemagokuYou can't pass any of the primitive data types as arguments to a generic method. The primitive data types: byte, short, int, long, float, double, boolean and char.

xenoepist Says:

Sep 4, 2011 - I was wondering why he used the object types instead of the primitives... thanks for clearing that out!

awesomelemonade Says:

Sep 4, 2011 - I would rather make a generic print method instead of doing System.out........like thispublic *T* void print(T x){System.out.println(x);}I kind of had to replaced the star with the carets because youtube wouldn't let me put caretsbecause i am LAZY (that's why)

mvdragon91 Says:

Oct 2, 2011 - java has unboxing and autoboxing so you can pass primative date types to a generic type. Only in java tho.

andrewcomr Says:

Oct 12, 2011 - one dislike! Really?

manasume Says:

Nov 6, 2011 - i get this error message, can someone tell me whyException in thread "main" java.lang.Error: Unresolved compilation problem: The method print(T[]) in the type GenericMethod is not applicable for the arguments (int[])

omg123596 Says:

Jan 7, 2012 - I'm getting errors.Here's my code: i.imgur(DOT)com/3OLqc.pngCan someone help me? :(

mihek Says:

Jan 24, 2012 - One question. How does the compareTo method determine which one of two Strings is greater?Thanks!

devilazpl Says:

Jan 29, 2012 - lol templates

devilazpl Says:

Jan 29, 2012 - right sir, basic types: int and char arent supported by Templatesall you need to do is changeint to Integer[] iray  and char to Character[] cray;they are upgraded types that are better version (have more methods) of these basic ones

Luvu5evr Says:

Feb 5, 2012 - The data type passed to a generic method must be of a reference type, aka a class name. You cannot replace a generic type (T, E, etc.) with a primitive type (int, char, etc.). You can use wrapper classes (Integer, Character, Double, etc.)  to get around this. Using these classes will make an actual instance of the class with the value you passed to it and the value is immutable, e.g. Integer myInteger = new Integer(5); Here, 5 is the value of the Integer instance & is unchangeable.

dasten123 Says:

Mar 22, 2012 - finally I understand why he wrote Integer[] instead of int[] :D

bloodsteam Says:

Mar 27, 2012 - Before watching this video I tried by myself to make a method that would do the job.public static void printMe(Object[] i) { for (Object x: i) System.out.printf("%s ", x); System.out.println();}Is this method equivalent or would it fail in some instances where bucky's would not?

saheds Says:

Mar 31, 2012 - if you have Netbeans Installed type 'sout' then press tab and it will print 'System.Out.println("")'. Much faster

BizarroFreak9991 Says:

Apr 3, 2012 - As far as I can tell it would do the job just fine, since all Objects are child-classes of the Object class.Using a generic method though, you can also access the type (in this case T), f. e. to compare it. So you could handleT instanceof Integer // differently thanT instanceof String.

c0decub Says:

Apr 9, 2012 - c++ templates

theculchie Says:

May 4, 2012 - very helpful, thank you!

Alexxv46 Says:

May 9, 2012 - теперь все понял, каюсь :)

Shopping | prank calls | Wholesale products | english movies | prank calls | proxy | links | prank call

Topfacebookvideos funny arabic videos

Privacy Policy