Java generics ❓

Поделиться
HTML-код
  • Опубликовано: 16 окт 2024

Комментарии • 214

  • @BroCodez
    @BroCodez  4 года назад +83

    //----------------------- 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 Год назад +1

      thank you so much
      love u bro
      forever subscriber

  • @Crispeaks
    @Crispeaks Год назад +27

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

  • @tomaszkarolak6179
    @tomaszkarolak6179 3 года назад +55

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

  • @john81487
    @john81487 Год назад +8

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

  • @angelcastineira2561
    @angelcastineira2561 4 года назад +45

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

  • @jojovstojo
    @jojovstojo Год назад +6

    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

  • @furki3556
    @furki3556 3 года назад +6

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

  • @rex.kishore
    @rex.kishore 11 месяцев назад +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 ...

  • @larkinthesky
    @larkinthesky 8 месяцев назад +1

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

  • @roxorsrule8604
    @roxorsrule8604 2 года назад +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!

  • @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 года назад +3

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

  • @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

  • @patrickjaposmack4573
    @patrickjaposmack4573 Год назад +2

    Excellent tutorial video about generic classes and methods!

  • @Naanu_kartik
    @Naanu_kartik 3 года назад +5

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

  • @Remolhunter97
    @Remolhunter97 3 года назад +3

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

  • @kedea159
    @kedea159 3 года назад +1

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

  • @faniliana
    @faniliana 3 года назад +1

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

  • @deeplife9654
    @deeplife9654 Год назад +2

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

  • @chris07ism
    @chris07ism Год назад +1

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

  • @SolutionByBrain1
    @SolutionByBrain1 Год назад

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

  • @anandchaudhary8952
    @anandchaudhary8952 3 года назад +31

    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 😁

    • @mariuspet89
      @mariuspet89 2 года назад +1

      Yes, his chanel is very good!

    • @ArielLorusso
      @ArielLorusso Год назад +8

      His channel is not generic

  • @sergeyb6071
    @sergeyb6071 4 года назад +8

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

  • @victoriagee1059
    @victoriagee1059 2 года назад

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

  • @lamias7712
    @lamias7712 2 года назад +1

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

  • @Ethhix
    @Ethhix 3 года назад +1

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

  • @ndthdproduction2900
    @ndthdproduction2900 2 года назад

    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

  • @EdgarLopez-dq6zv
    @EdgarLopez-dq6zv Год назад

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

  • @ginasomara267
    @ginasomara267 3 года назад +1

    most helpful generics video on the internet. hands down

  • @mihirkohli4804
    @mihirkohli4804 3 года назад +3

    please do data structure
    love your content

  • @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.

  • @kkspuder
    @kkspuder 7 месяцев назад

    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

  • @weonios
    @weonios 2 месяца назад

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

  • @zxnnightstalker2289
    @zxnnightstalker2289 3 года назад +1

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

  • @diamonddunyasi4945
    @diamonddunyasi4945 2 года назад

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

  • @OneGrindyBoi
    @OneGrindyBoi Месяц назад

    unparalleled at teaching, thanks bro

  • @atongpayatoyatu2760
    @atongpayatoyatu2760 3 года назад

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

  • @Snowmanver2
    @Snowmanver2 2 года назад

    best channel with best tutorials out there!

  • @traveltheworld5241
    @traveltheworld5241 Год назад

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

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

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

  • @acemanftw
    @acemanftw 4 года назад +5

    instantly subbed after that intro :)

    • @BroCodez
      @BroCodez  4 года назад +3

      yassss! thanks aceman

  • @chap_01
    @chap_01 2 года назад

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

  • @waleedharalkathiri1836
    @waleedharalkathiri1836 3 года назад

    THE BEST EVER EXPLENATION OF GENERIC CLASS AND METHODS IN RUclips HISTORY🤣

  • @mariuspet89
    @mariuspet89 2 года назад

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

  • @chromeshock3774
    @chromeshock3774 Год назад

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

  • @Garrison86
    @Garrison86 2 года назад

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

  • @kedarsambhus3623
    @kedarsambhus3623 3 года назад

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

  • @jaaeamor7901
    @jaaeamor7901 2 года назад

    Thanks for making this tutorial. Appreciate it 👍

  • @benderbg
    @benderbg Год назад

    Great explanation of an important topic. Thanks Bro!

  • @dashunderscore7470
    @dashunderscore7470 Год назад +1

    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.

  • @NatyTor
    @NatyTor 2 года назад

    ho mannnnnnn your video are so clearly and amazing!! love you bro! thanks for all!

  • @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!

  • @hardcoded6325
    @hardcoded6325 2 года назад

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

  • @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.

  • @Elan_Altair
    @Elan_Altair 2 года назад

    This was really helpful for my exams ,Tq broooooooooo

  • @swankitydankity297
    @swankitydankity297 3 года назад +1

    Fantastic tutorial! Thank you so much :)

  • @DuygamingBlogspot
    @DuygamingBlogspot Месяц назад

    I really understand what is arraylist😊

  • @aruldilip9430
    @aruldilip9430 2 года назад

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

  • @tunghuynh8504
    @tunghuynh8504 3 года назад

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

  • @nawfalnjm5699
    @nawfalnjm5699 3 года назад

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

  • @wolanus
    @wolanus 3 года назад +1

    Thanks for the tutorial, Bro.

  • @Say2Cups
    @Say2Cups 4 месяца назад

    This the guy that taught me how to code fr

  • @emilgabriel81
    @emilgabriel81 3 года назад

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

  • @fitzsimmons7
    @fitzsimmons7 9 месяцев назад

    this was helpful, exploded my brain, thanks

  • @comrade107
    @comrade107 10 месяцев назад

    You are awesome! Thanks for all the help!!

  • @quarduroy1
    @quarduroy1 Год назад

    Phenomenal explanation, thank you

  • @GenjaOrigins
    @GenjaOrigins 2 года назад

    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

  • @codeevolution1
    @codeevolution1 5 месяцев назад

    best teacher on youtube❤❤

  • @syednizam8616
    @syednizam8616 2 года назад

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

  • @darianchan4649
    @darianchan4649 3 года назад

    very nice tutorial bro keep em coming !

  • @OnlyOneGedeon
    @OnlyOneGedeon 3 года назад

    Thank you for this very helpful video

  • @dbvs007
    @dbvs007 2 года назад

    Awesome 👏

  • @calebkrauter4027
    @calebkrauter4027 8 месяцев назад

    Very helpful! Thank you.

  • @miuwai6211
    @miuwai6211 2 года назад

    Very clear explanation. Thank you Bro. :)

  • @nasseranaoui3315
    @nasseranaoui3315 Год назад

    That was a good tutorial , thanks :D

  • @anonimanonim1223
    @anonimanonim1223 2 года назад

    Great

  • @mustapharaimilawal8053
    @mustapharaimilawal8053 3 года назад

    Thanks a lot for this amazing tutorial.

  • @kyomuhendoprecious8414
    @kyomuhendoprecious8414 2 года назад +1

    Thanks alot

  • @walterwhite2418
    @walterwhite2418 Год назад

    Great video thx for your effort !!

  • @ozbayhilmi
    @ozbayhilmi 8 месяцев назад

    Thank you for this video.

  • @d.4hveed
    @d.4hveed 3 года назад

    Very good explanation!! Thank u

  • @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.

  • @SoumilSahu
    @SoumilSahu 2 года назад

    Thanks a lot, this was really helpful!

  • @andreajeanbatchelor5142
    @andreajeanbatchelor5142 2 года назад

    Great examples!

  • @kaushalprasadyadav9242
    @kaushalprasadyadav9242 2 года назад

    Great work bro👍

  • @andersontiban5356
    @andersontiban5356 Год назад

    so helpful thankyou

  • @chamindilhara5765
    @chamindilhara5765 Год назад

    thanks for teach us

  • @quanyufeng579
    @quanyufeng579 3 года назад

    Wonderful!!

  • @v1krv
    @v1krv 2 года назад

    Well explained

  • @hgatl
    @hgatl 3 года назад

    Awesome explaining, thx bro!

  • @thronegamesfm
    @thronegamesfm Год назад

    Thank you bro! Very useful video

  • @yojan69
    @yojan69 9 месяцев назад

    so does people usually write T but you like to write Thing as you mentioned before or nah?

  • @kemann3815
    @kemann3815 2 года назад

    Wow. Magnificent

  • @almanduku9043
    @almanduku9043 3 года назад

    Very useful lesson , thank you sir :)))

  • @janjeromesoriano1182
    @janjeromesoriano1182 3 года назад

    Thank you, it's very helpful.

  • @yifansu8432
    @yifansu8432 Год назад

    This video is sooooooo awsome.......

  • @alexreznitsky6338
    @alexreznitsky6338 Год назад

    Thanks a lot!!! great explanation!

  • @marybenish9716
    @marybenish9716 2 года назад

    Love this channel!

  • @mackymichel8052
    @mackymichel8052 3 года назад

    Great.

  • @dieseldust5315
    @dieseldust5315 3 года назад

    Great Tutorial!