#25 Method Overloading in Java

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

КОМЕНТАРІ • 31

  • @yitingchen8278
    @yitingchen8278 Рік тому +24

    Class can have same name methods, only requirement is they should have different parameters, name and type is important!

    • @bestlearn6131
      @bestlearn6131 Рік тому +3

      Don't make it harder by your complicated words

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

      @@bestlearn6131 that's not hard at all he just gave simple definition 😃

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

      @@bestlearn6131 knowing the meaning of those words is necessary to understand what a method overloading really does...

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

      ​@@bestlearn6131he just explained 6min video in two sentences

  • @shazirnazir3501
    @shazirnazir3501 Рік тому +5

    class Calculator {
    int add(int... numbers) {
    int sum = 0;
    for (int num : numbers) {
    sum += num;
    }
    return sum;
    }
    }
    public class Main {
    public static void main(String[] args) {
    Calculator calc = new Calculator();
    System.out.println(calc.add(5, 6));
    System.out.println(calc.add(5, 6, 7));
    System.out.println(calc.add(5, 6, 7, 8));
    }
    }

  • @vinaykumarbandarapalli216
    @vinaykumarbandarapalli216 Рік тому +7

    I feel Java is unable to satisfy user requirements here.. I may return a value I may not return a value with same type and number of arguments. But Java doesn't support that.

  • @syeddanish5334
    @syeddanish5334 11 місяців тому +2

    Best explanation sir

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

    Easy to understand and concise!

  • @Dbsski
    @Dbsski 11 місяців тому +2

    Thank you so much sir😊

  • @mdmahboob-zj3kd
    @mdmahboob-zj3kd Місяць тому

    good explanation....👏

  • @rudra2036
    @rudra2036 5 місяців тому

    I think JavaScript handle's this issue quite interestingly with the help of rest parameter.

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

    Great teaching skills

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

    Sir class can be one type of function because in other language it's have same syntax somewhat

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

    When we return double value, the variable in main class to which the value will be assigned should also be of the type double, right?

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

      Yes........!!
      Your output will be XY.00

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

    Thank you sir 😊❤

  • @AmalManoj-m9z
    @AmalManoj-m9z 9 місяців тому +1

    sir could you help how to give input into java like scanf in c

    • @aryankarthik3838
      @aryankarthik3838 Місяць тому

      Scanner sc = new Scanner(System.in);
      System.out.println("Enter the number: ");
      int num = sc.nextInt();

  • @SaurabhSingh-jx9xr
    @SaurabhSingh-jx9xr 27 днів тому

    I have a Question, Why are you using public keyword inside Calculator Class with various methods, i think its not needed sir .

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

    Can you make a video on JavaDoc?

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

    i know very out of subject thing
    i kinda went back in nostalgia when he said got7 at 2:00
    💚💚💚💚

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

    Bhupendra jogi

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

    No two methods with same name must have same parameter type and same number of parameters.

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

    genuine

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

    Kuss marwa rha h english accent dekh apna

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

    nothing 🤣

  • @GOLLAPALLIAKKULAPPAGARIHRUTHIK

    sir in this video u took same method name "add" then how could the class demo can understand which one need to take

    • @Mad-manOfficialPlay
      @Mad-manOfficialPlay Рік тому +1

      Just simple as in parameter u should mention the values as it mention in the method...Java will take the crt parameter and complie the value polymorphism