Java generics ❓

Поділитися
Вставка
  • Опубліковано 22 лис 2024

КОМЕНТАРІ • 220

  • @BroCodez
    @BroCodez  4 роки тому +85

    //----------------------- Generic Method -----------------------
    public class Main {
    public static void main(String args[]) {

    Integer[] intArray = {1, 2, 3, 4, 5};
    Double[] doubleArray = {5.5, 4.4, 3.3, 2.2, 1.1};
    Character[] charArray = {'H', 'E', 'L', 'L', 'O'};
    String[] stringArray = {"B","Y","E"};
    System.out.print("Integer Array: ");
    displayArray(intArray);
    System.out.println(firstIndex(intArray));
    System.out.print("Double Array: ");
    displayArray(doubleArray);
    System.out.println(firstIndex(doubleArray));
    System.out.print("Character Array: ");
    displayArray(charArray);
    System.out.println(firstIndex(charArray));

    System.out.print("String Array: ");
    displayArray(stringArray);
    System.out.println(firstIndex(charArray));
    */
    }

    // Generic method
    public static void displayArray(Thing[] array) {
    for(Thing x : array) {
    System.out.print(x+" ");
    }
    System.out.println();
    }

    // Generic method with generic return type
    public static Thing firstIndex(Thing[] array) {
    return array[0];
    }
    }
    //----------------------- Generic Class -----------------------
    public class Main {
    public static void main(String args[]) {

    //bounded types = you can create the objects of a generic class to have data
    // of specific derived types ex.Number

    MyGenericClass myInt = new MyGenericClass(1,9);
    MyGenericClass myDouble = new MyGenericClass(3.14,1.01);
    //MyGenericClass myChar = new MyGenericClass('@','$');
    //MyGenericClass myString = new MyGenericClass("Hello",'!');


    System.out.println(myInt.getValue());
    System.out.println(myDouble.getValue());
    //System.out.println(myChar.getValue());
    //System.out.println(myString.getValue());
    }
    }
    // ----------------------------------------------------------------
    public class MyGenericClass {
    Thing x;
    Thing2 y;

    MyGenericClass(Thing x, Thing2 y){
    this.x = x;
    this.y = y;
    }

    public Thing2 getValue() {
    return y;

    }
    }

    • @TechnoSan09
      @TechnoSan09 2 роки тому +1

      thank you so much
      love u bro
      forever subscriber

  • @Crispeaks
    @Crispeaks Рік тому +34

    Single-handedly taught me Generics and helped me complete an assignment in 30 minutes. Epic!

  • @tomaszkarolak6179
    @tomaszkarolak6179 4 роки тому +59

    The best tutorials, I've ever seen on YT, thx bro!!!

  • @deeplife9654
    @deeplife9654 Рік тому +6

    Let start a campaign to give bro best teacher on youtube award !!!!!
    ❤❤❤❤❤❤❤ .

  • @john81487
    @john81487 Рік тому +10

    I always go through one of these videos before starting my bootcamp lessons. It makes everything so much easier to get into.

  • @patrickjaposmack4573
    @patrickjaposmack4573 Рік тому +4

    Excellent tutorial video about generic classes and methods!

  • @jojovstojo
    @jojovstojo Рік тому +8

    Bro this was the heaviest video of all till now ! Literally my brain just exploded ! But extremely simple and direct - So thank you for such a badass of a teacher

  • @ChrisTDBCODE
    @ChrisTDBCODE День тому

    My professor sucks and ever since I started coming here instead of their lectures, my grade went from a B to an A. Thank you Brofessor!

  • @larkinthesky
    @larkinthesky 9 місяців тому +1

    You, my dear Sir, are a legend. Thank you so much for all these incredibly useful instructional videos.

  • @angelcastineira2561
    @angelcastineira2561 4 роки тому +48

    a lot of new stuff but really well explained, thanks!

  • @furki3556
    @furki3556 3 роки тому +6

    you have really the best tutorials I have ever seen, thank you. greetings from germany

  • @ravenguirao9081
    @ravenguirao9081 Рік тому +2

    Thanks, I finally understand Generics, some code training/bootcamps explain it really complicated.. but with you i realized it's just that simple.

  • @karanbrar1934
    @karanbrar1934 3 роки тому +4

    That 1 dislike is from bro himself, just to keep himself humble... ;)

  • @rex.kishore
    @rex.kishore Рік тому +2

    Well said Bro, you did exactly what we want. The Duration with perfect explanation, great effort that you spend on it. It pay off man. Good Luck ...

  • @roxorsrule8604
    @roxorsrule8604 3 роки тому +15

    Wow, I'm glad I found your channel. You style is crystal clear and to the point. Although I'm taking other classes you clarify the points I was having trouble with. Thanks man!

  • @faniliana
    @faniliana 3 роки тому +1

    This would be the best java tutorial videos out there. Thank you bro

  • @brianwkinyua
    @brianwkinyua 21 день тому +1

    very clear and comprehensive. thank you again.

  • @victoriagee1059
    @victoriagee1059 3 роки тому

    Your code is so clean. You really know what you are doing!!!!

  • @SolutionByBrain1
    @SolutionByBrain1 Рік тому

    You are so smart to simplify such big task in a simple ways
    Thank you bro!
    Of Eritrea 🇪🇷

  • @marke4246
    @marke4246 2 роки тому +4

    I just learned more from a twenty minute video than a two hour lecture from my professor. You have a new bro.

  • @kedea159
    @kedea159 3 роки тому +1

    Really the best tutorials on UA-cam, that I've seen, keep up the good work Bro!

  • @murrayKorir
    @murrayKorir 2 роки тому

    well explained especially that part of where you can use 'Thing' instead of 'T' clears the mystery behind why is it always T,E or S.

  • @chris07ism
    @chris07ism Рік тому +1

    Thanks again for another relatively simple concept explained in a brilliant way.

  • @ginasomara267
    @ginasomara267 3 роки тому +1

    most helpful generics video on the internet. hands down

  • @Naanu_kartik
    @Naanu_kartik 3 роки тому +5

    concept cleared 🙌 Thanks Bro...and you have an unique way of explaining the things.

  • @anandchaudhary8952
    @anandchaudhary8952 3 роки тому +35

    Finally after spending 2 days reading the chapter and going over rigerious examples and still being clueless, I've understood generics. Love the channel name 😁

  • @НікітаОрлов-с3ч

    You are the best !!! Thanks for lessons in 2023

  • @mohammadreza_arman
    @mohammadreza_arman 15 годин тому

    Good job bro. That's exactly how you teach sth. I'm very glad that I found this amazing channel. Keep going on

  • @traveltheworld5241
    @traveltheworld5241 Рік тому

    Self learning but I understand easily ,this guy is awesome...

  • @OneGrindyBoi
    @OneGrindyBoi 2 місяці тому

    unparalleled at teaching, thanks bro

  • @waleedharalkathiri1836
    @waleedharalkathiri1836 3 роки тому

    THE BEST EVER EXPLENATION OF GENERIC CLASS AND METHODS IN UA-cam HISTORY🤣

  • @lamias7712
    @lamias7712 3 роки тому +1

    Thank you so much for your simplified explanation . Straight to the point.

  • @weonios
    @weonios 3 місяці тому

    The best video for Generics I have ever seen, and the examples are pretty nice!

  • @sergeyb6071
    @sergeyb6071 4 роки тому +8

    wow that's a lot of stuff in one tutorial 🤯👍

  • @av2678
    @av2678 2 роки тому +5

    Wow! Generic is so damn useful. I wish i saw this video yesterday lol but still, better than never. Well explained too

  • @atongpayatoyatu2760
    @atongpayatoyatu2760 3 роки тому

    what the hell so good java tutorial i ever saw in youtube. thank you very much!

  • @OnlyOneGedeon
    @OnlyOneGedeon 3 роки тому

    Thank you for this very helpful video

  • @aruldilip9430
    @aruldilip9430 2 роки тому

    I learnt lot of things so far from the above 83 videos

  • @Remolhunter97
    @Remolhunter97 3 роки тому +3

    Best tutorials ever, holy shit it's pleasant to learn looking your videos bro, keep going !

  • @zxnnightstalker2289
    @zxnnightstalker2289 4 роки тому +1

    Very clear explanation. My first clear understanding comes from you. Thanks a lot. ;)

  • @GenjaOrigins
    @GenjaOrigins 3 роки тому

    I was rejected in interview cause i didnt know what is generics and i saw that in their code xd, i saw many in a generic method. Thx

  • @kkspuder
    @kkspuder 8 місяців тому

    really thx bro, though i'm watched some videos about generics, i'm still struggling with its use, here's some examples also other videos i watched but i'm not got a good understanding until you open the ArrayList class, everything is clear, i got the key point , this is really a nice video

  • @chamindilhara5765
    @chamindilhara5765 2 роки тому

    thanks for teach us

  • @mihirkohli4804
    @mihirkohli4804 3 роки тому +3

    please do data structure
    love your content

  • @mariuspet89
    @mariuspet89 2 роки тому

    Very nice video. You have a nice way of explaining programming concepts.

  • @Ethhix
    @Ethhix 3 роки тому +1

    Thank you for making this video, it was very helpful and informative! I appreciate it.

  • @kedarsambhus3623
    @kedarsambhus3623 3 роки тому

    Amazing! Easy to understand explanation to generics. Thanks bro.

  • @benderbg
    @benderbg Рік тому

    Great explanation of an important topic. Thanks Bro!

  • @diamonddunyasi4945
    @diamonddunyasi4945 2 роки тому

    Thx Bro I think you were descend from the sky 😀. We are waiting for more tutorials... Thank you

  • @Snowmanver2
    @Snowmanver2 2 роки тому

    best channel with best tutorials out there!

  • @DuygamingBlogspot
    @DuygamingBlogspot 2 місяці тому

    I really understand what is arraylist😊

  • @codeevolution1
    @codeevolution1 7 місяців тому

    best teacher on youtube❤❤

  • @chap_01
    @chap_01 2 роки тому

    Nice channel, nice english, nice elocution, nice explaining.

  • @jaaeamor7901
    @jaaeamor7901 2 роки тому

    Thanks for making this tutorial. Appreciate it 👍

  • @syednizam8616
    @syednizam8616 2 роки тому

    I liked your end of the session music and fast forward music. What are those?

  • @andersontiban5356
    @andersontiban5356 Рік тому

    so helpful thankyou

  • @quarduroy1
    @quarduroy1 Рік тому

    Phenomenal explanation, thank you

  • @EdgarLopez-dq6zv
    @EdgarLopez-dq6zv Рік тому

    I really like your videos. You explain complex concepts appears easy, thx man

  • @anonimanonim1223
    @anonimanonim1223 2 роки тому

    Great

  • @dbvs007
    @dbvs007 2 роки тому

    Awesome 👏

  • @kyomuhendoprecious8414
    @kyomuhendoprecious8414 2 роки тому +1

    Thanks alot

  • @chromeshock3774
    @chromeshock3774 Рік тому

    Dam, these videos are gold! So helpful in my bootcamp.

  • @Say2Cups
    @Say2Cups 6 місяців тому

    This the guy that taught me how to code fr

  • @ferfykins
    @ferfykins 3 роки тому

    Can you create a generic arraylist to hold multiple types, for example: ArrayList newList = new ArrayList(); ??? Thanks for video, explained very well.

  • @Elan_Altair
    @Elan_Altair 2 роки тому

    This was really helpful for my exams ,Tq broooooooooo

  • @ndthdproduction2900
    @ndthdproduction2900 3 роки тому

    That's so good for the basic bro ! Hope you do more a bout advanced like more complex generic methods. Hope you doing well bro

  • @mackymichel8052
    @mackymichel8052 3 роки тому

    Great.

  • @Garrison86
    @Garrison86 2 роки тому

    Amazing! thanks for this awesome explanation, really appreciate your videos.

  • @v1krv
    @v1krv 3 роки тому

    Well explained

  • @ozbayhilmi
    @ozbayhilmi 10 місяців тому

    Thank you for this video.

  • @dashunderscore7470
    @dashunderscore7470 2 роки тому +2

    i am a fellow bro 😎, bro code plaese keep creating videos about java, there are very less content on youtube about java, everyone is posting videos about python , javascript but no one explaining java🥲 , thank you bro.

  • @quanyufeng579
    @quanyufeng579 3 роки тому

    Wonderful!!

  • @wolanus
    @wolanus 4 роки тому +1

    Thanks for the tutorial, Bro.

  • @hardcoded6325
    @hardcoded6325 3 роки тому

    very good, the best explanetion in the word!!! (i'm from Brazil)

  • @d.4hveed
    @d.4hveed 3 роки тому

    Very good explanation!! Thank u

  • @acemanftw
    @acemanftw 4 роки тому +5

    instantly subbed after that intro :)

    • @BroCodez
      @BroCodez  4 роки тому +3

      yassss! thanks aceman

  • @emilgabriel81
    @emilgabriel81 3 роки тому

    Loud and clear, on topic, nice animations, your channel is quite underrated

  • @Ege39
    @Ege39 3 роки тому

    Nice

  • @swankitydankity297
    @swankitydankity297 3 роки тому +1

    Fantastic tutorial! Thank you so much :)

  • @fitzsimmons7
    @fitzsimmons7 10 місяців тому

    this was helpful, exploded my brain, thanks

  • @comrade107
    @comrade107 11 місяців тому

    You are awesome! Thanks for all the help!!

  • @mustapharaimilawal8053
    @mustapharaimilawal8053 3 роки тому

    Thanks a lot for this amazing tutorial.

  • @tunghuynh8504
    @tunghuynh8504 3 роки тому

    Thanks Bro, this help me to easily understand the basic concept of Generics in Java

  • @calebkrauter4027
    @calebkrauter4027 9 місяців тому

    Very helpful! Thank you.

  • @andreajeanbatchelor5142
    @andreajeanbatchelor5142 2 роки тому

    Great examples!

  • @almanduku9043
    @almanduku9043 3 роки тому

    Very useful lesson , thank you sir :)))

  • @alanwarthon
    @alanwarthon Рік тому

    Nice, thanks

  • @deeplife9654
    @deeplife9654 Рік тому

    Generic : same method and class but you can use these method and class for any data type instead of one specific data type

  • @VeeGotThePower
    @VeeGotThePower Рік тому

    Let's Go!!!!! At the end of your Java Playlist!!!!

  • @yfchina143
    @yfchina143 3 роки тому

    i swear all the videos 1-3rd comment is best video ever, but which 1 is the best?!

  • @janjeromesoriano1182
    @janjeromesoriano1182 3 роки тому

    Thank you, it's very helpful.

  • @MrLoser-ks2xn
    @MrLoser-ks2xn 2 роки тому

    Thanks

  • @Thannila.G-l6b
    @Thannila.G-l6b 11 днів тому

    Thankyou so much

  • @miuwai6211
    @miuwai6211 2 роки тому

    Very clear explanation. Thank you Bro. :)

  • @nawfalnjm5699
    @nawfalnjm5699 3 роки тому

    man this video is full of great info , thank you so much !

  • @yahelbraun5471
    @yahelbraun5471 4 роки тому +3

    Great video! Just one question, how can you limit so you can enter only chars and strings?

    • @BroCodez
      @BroCodez  4 роки тому +3

      There doesn't appear to be any easy way to do so since the Character and String classes are in different type hierarchies

    • @yahelbraun5471
      @yahelbraun5471 4 роки тому +2

      @@BroCodez ok thanks, keep up the good work!

  • @abvy25
    @abvy25 3 роки тому

    Best explanation...

  • @ethankates5359
    @ethankates5359 Рік тому

    very helpful, thank you

  • @kemann3815
    @kemann3815 3 роки тому

    Wow. Magnificent

  • @bilalnizamani7447
    @bilalnizamani7447 3 роки тому

    can we use Object class refer instead of Generic ? are they both the same? if not please explain.

    • @parindyapigera1790
      @parindyapigera1790 Рік тому

      Well, Technically yes we can but there are so many disadvantages when using Object class, But if we use Generics its not complicated as Object. And also Generics is flexible and safe. At the same time, when we are working with Object it requires type-casting which lead us to so many errors.