#46 Anonymous Object in java

Поділитися
Вставка
  • Опубліковано 17 січ 2023
  • Check out our courses:
    Enterprise Java Spring Microservices: go.telusko.com/enterpriseJava
    Coupon: TELUSKO10 (10% Discount)
    Master Java Spring Development : bit.ly/java-spring-cloud
    Coupon: TELUSKO20 (20% Discount)
    Udemy Courses:
    Java:- bit.ly/JavaUdemyTelusko
    Spring:- bit.ly/SpringUdemyTelusko
    Java For Programmers:- bit.ly/javaProgrammers
    For More Queries WhatsApp or Call on : +919008963671
    website : courses.telusko.com/
    In this lecture we will learn:
    - Object creation in Java
    - Anonymous objects in Java
    - Difference between Simple objects and Anonymous objects
    #1
    In JVM, we have both stack memory and heap memory.
    - Object is created in the heap memory that contains variable and methods, it also have some address.
    - A obj=new A();
    obj.show();
    here, A is the classname.
    obj refers to the address say 101
    show() is a method that is called using reference variable obj.
    - Every time you call an object, it will call the constructor as well.
    - Object creation can be done in two ways:
    1. Declare an object - creating a reference
    2. Creating an object - and assigning the value to it
    e,g., A obj;
    obj=new A();
    *new A() shows that you are creating an object.
    - Reference of an object is created in the stack.
    #2
    Anonymous Objects:-
    Anonymous objects are simply created by using the new keyword.
    - It does not have any reference for an anonymous object.
    e.g., new A();
    - A method can directly be called using this object.
    new A().show();
    - We can't use the same anonymous object again. It will be use only for one time.
    Github repo : github.com/navinreddy20/Javac...
    Java:- bit.ly/JavaUdemyTelusko
    Spring:- bit.ly/SpringUdemyTelusko
    More Learning :
    Java :- bit.ly/3x6rr0N
    Python :- bit.ly/3GRc7JX
    Django :- bit.ly/3MmoJK6
    JavaScript :- bit.ly/3tiAlHo
    Node JS :- bit.ly/3GT4liq
    Rest Api :-bit.ly/3MjhZwt
    Servlet :- bit.ly/3Q7eA7k
    Spring Framework :- bit.ly/3xi7buh
    Design Patterns in Java :- bit.ly/3MocXiq
    Docker :- bit.ly/3xjWzLA
    Blockchain Tutorial :- bit.ly/3NSbOkc
    Corda Tutorial:- bit.ly/3thbUKa
    Hyperledger Fabric :- bit.ly/38RZCRB
    NoSQL Tutorial :- bit.ly/3aJpRuc
    Mysql Tutorial :- bit.ly/3thpr4L
    Data Structures using Java :- bit.ly/3MuJa7S
    Git Tutorial :- bit.ly/3NXyCPu
    Donation:
    PayPal Id : navinreddy20
    www.telusko.com
  • Наука та технологія

КОМЕНТАРІ • 10

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

    Two times constructor running means two new object created.
    Got it. 🥳

  • @satyadsp3906
    @satyadsp3906 10 місяців тому +6

    "Everyone hates this type of people" - Telusko to people who get 99/100 😂😂😂 man ur funny

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

    I'm a big fan of your python tutorial,

  • @jenilcaptain6295
    @jenilcaptain6295 3 дні тому

    need a video on garbage collection

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

    creating an object without reference , which can be deleted by garbage collection ryt?

  • @user-qn7lt2xb1n
    @user-qn7lt2xb1n Місяць тому

    Whats the use of these anonymous objects?

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

    deep talks

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

    👍

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

    public class Main{
    public static void main(String[] args) {//Main method
    A a = new A();//Constructor and object creation
    a.Announcement();//Method call
    new A().Announcement();//Anonymous object and method call
    }
    }
    class A{//parent class

    public A(){
    //Constructor
    System.out.println("
    Object created.");
    }
    public void Announcement(){
    System.out.println("NOW in A!");
    }
    }

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

    I give you 99 for teaching, but I can't hate you😅