12.3 Object Serialization in java | Serializable Interface

Поділитися
Вставка
  • Опубліковано 19 жов 2024
  • The String class and all the wrapper classes implements java.io.Serializable interface by default. Deserialization is the reverse operation of serialization.
    Serialization in java is a mechanism of writing the state of an object into a byte stream.
    Check out our courses:
    Spring Boot and Microservices Live Course : go.telusko.com...
    Coupon: TELUSKO10 (10% Discount)
    Complete Java Developer Course Batch-3: go.telusko.com...
    Coupon: TELUSKO10 (10% Discount)
    Enterprise Java Spring Microservices: go.telusko.com...
    Coupon: TELUSKO10 (10% Discount)
    Master Java Spring Development : go.telusko.com...
    Coupon: TELUSKO20 (20% Discount)
    Udemy Courses:
    Spring: go.telusko.com...
    Java:- go.telusko.com...
    Java Spring:- go.telusko.com...
    Java For Programmers:- go.telusko.com...
    Python : go.telusko.com...
    Git : go.telusko.com...
    Docker : go.telusko.com...
    For More Queries WhatsApp or Call on : +919008963671
    website : courses.telusk...
    Follow Navin Reddy on Instagram: / navinreddy20
    Subscribe to our other channel:
    Navin Reddy : / @navinreddy
    Telusko Hindi :
    / @teluskohindi
    Subscribe to the channel and learn Programming in easy way.
    Java Tutorial for Beginners: goo.gl/p10QfB
    C Tutorial Playlist : goo.gl/8v92pu
    Android Tutorial for Beginners Playlist : goo.gl/MzlIUJ
    XML Tutorial : goo.gl/Eo79do
    Design Patterns in Java : goo.gl/Kd2MWE
    Socket Programming in Java : goo.gl/jlMEbg
    Spring MVC Tutorial : goo.gl/9ubbG2
    OpenShift Tutorial for Beginners : goo.gl/s58BQH
    Spring Framework with Maven : goo.gl/MaEluO
    Sql Tutorial for Beginners : goo.gl/x3PrTg
    String Handling in Java : goo.gl/zUdPwa
    Array in Java : goo.gl/uXTaUy
    Java Servlet : goo.gl/R5nHp8
    Exception Handling in Java : goo.gl/N4NbAW

КОМЕНТАРІ • 93

  • @brunofilgueiras3518
    @brunofilgueiras3518 6 років тому +32

    man, thanks for this material, the way you explained, the sequence of each idea was just perfect.

  • @amanmishra98apr
    @amanmishra98apr 4 роки тому +9

    Very useful lecture for me...Thank you sir, I'm following you from 3 years.

  • @RaviKumar-n8k6g
    @RaviKumar-n8k6g 9 місяців тому

    the way of teaching via is code is really understandable more than read a theory in 30 minutes,thanks i will continue to watch ur videos..

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

    You and Durga sir are wizards in JAVA!!!

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

    At 2:15, you mentioned, Save obj1 = obj will create a copy of obj. It's not correct. obj2 will point to the same object as obj, it is just a reference; no copying occurs here.

  • @NexGenSlayer
    @NexGenSlayer 4 роки тому +12

    You shouldn't keep saying the "NULL" object has a value of zero -- it is simply null. There is a big difference in these two things.

  • @slobodantajisic2762
    @slobodantajisic2762 6 років тому +11

    It is strongly recommended that all serializable classes explicitly declare serialVersionUID values, since the default serialVersionUID computation is highly sensitive to class details that may vary depending on compiler implementations, and can thus result in unexpected InvalidClassExceptions during deserialization...

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

      how to do so?

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

      private static final long serialVersionUID = 4L; insinde the class with implements serialization

  • @natsnettesfamariam7868
    @natsnettesfamariam7868 5 років тому +2

    Thank you Telusko. You are really good teacher.
    I always see your tutorials.
    in this example are we saving the object over a network???????

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

      Not exactly, Here we are saving the object in a text file(Serializing).
      After saving the file, you can transfer the file (containing our object) over network.
      After receiving the file from the other end of network, we can read the object(De-Serialize) from the received file.
      In this particular scenario, both serialization and de-serialization are done in the same machine(without our network step involved).

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

    Excellent Example, just Legend!

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

    best explanation. Thank you

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

    Super explanation, thanks for your time!

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

    great video. I just wanted to ask what is the difference between ObjectOutputStream and DataOutputStream?

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

    Thank you Telusko for the amazing explanation. I just got a doubt while watching this video. What is the difference between saving objects and saving data? I'm curious to know the difference between data and objects.

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

    Hi John, can you please make a video about serialization, I don't understand a thing about it and the tutorials on youtube are hard to understand, they're old too. I hope you see this, thanks a lot, you've helped me a lot in java

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

    He haven't closed the objectoutput stream

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

    Thank you for this very useful video!

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

    excellent sessio. one question, will object code also get serialized and deserialized or only variable values?

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

    such a badass explaination

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

    you r my best teacher

  • @hwangclara4024
    @hwangclara4024 6 років тому +5

    Can you please explain Serialization with static variables and transient? It will be better.

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

    Thank you... concept got cleared

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

    You are a god.

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

    Simple + effective

  • @ShivamKendre-fc3su
    @ShivamKendre-fc3su 2 місяці тому

    great video

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

    great tutorial man

  • @premkumar-jz4di
    @premkumar-jz4di 2 роки тому

    super sir well explained

  • @adilsaju
    @adilsaju 5 років тому

    Awesome video man. Keep it up.

  • @mekings0422
    @mekings0422 4 роки тому

    This is an amazing tutorial, exactly what I was looking for... thanks a lot bro

  • @vladanulardzic5859
    @vladanulardzic5859 5 років тому +1

    Well done ! Keep on.

  • @mohammedviso2269
    @mohammedviso2269 7 років тому +1

    Great tutorial.......Thanks

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

    The best✨

  • @mr.RAND5584
    @mr.RAND5584 4 роки тому

    Is that sir updatable? Like mysql, excel , word ?

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

    Thank you

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

    does memory is created for obj1 in heap when we say Save obj1 = (Save) ois.readObject();

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

    Awesome!!! Thank you!

  • @abddesd1492
    @abddesd1492 6 років тому

    can we you any marker interface interchangable ,for example instead of serializable can we use clonable interface is it posssible

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

    Sir in mine.. i can't see my saved file obj.txt..
    Actually I searched it. But file is not saved

  • @clawciita
    @clawciita 6 років тому

    great video! just what I was looking for

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

    How do I find the previous video? 🥺

  • @m3r5
    @m3r5 6 років тому +2

    Obj1=obj will not copy the values
    It will copy the reference of obj into obj1
    Clear your concepts first

    • @kumarans8543
      @kumarans8543 5 років тому

      It will copy bro. Just code it and check

    • @m3r5
      @m3r5 5 років тому

      @@kumarans8543 class temp
      { int x,y;
      temp()
      {
      x=0;y=0;
      }
      temp(int x,int y)
      {
      this.x=x;
      this.y=y;
      }
      }
      class Ref
      {
      public static void main(String[] args)
      {
      temp t1=new temp(100,200);
      temp t2=new temp();
      System.out.println("t1 values
      X ="+t1.x+" \tY = "+t1.y);
      System.out.println("t2 values
      X ="+t2.x+" \tY = "+t2.y);
      t2=t1; //if it will copy objects then changes made to any of the objects will not reflect the other object
      System.out.println("After t1 values
      X ="+t1.x+" \tY = "+t1.y);
      System.out.println("After t2 values
      X ="+t2.x+" \tY = "+t2.y);
      t2.x=400;
      t2.y=500;

      System.out.println("NOW t1 values
      X ="+t1.x+" \tY = "+t1.y);
      System.out.println("NOW t2 values
      X ="+t2.x+" \tY = "+t2.y);
      }
      }

    • @m3r5
      @m3r5 5 років тому

      @@kumarans8543 Just copy and run my code
      It will not copy values bro, it will copy reference of the object. That's why changes made reflects on both objects

    • @kumarans8543
      @kumarans8543 5 років тому

      @@m3r5 copying reference means that they point to the same object na? thats what i meant by 'copying the value' , It's like same value referred by diff objects

    • @guitarsrevived9493
      @guitarsrevived9493 5 років тому

      yeah bro exactly !!!

  • @datsonyan3499
    @datsonyan3499 6 років тому

    nicely explained.

  • @MadForCs16
    @MadForCs16 4 роки тому

    nice and simple.

  • @sahilkhotkar3574
    @sahilkhotkar3574 6 років тому +2

    Thanks,helped a lot

  • @ramadevivakkalanka2998
    @ramadevivakkalanka2998 9 років тому +2

    Nice workdone .. Thank you...

  • @SyedMuhammadAli-tr4cg
    @SyedMuhammadAli-tr4cg Рік тому +1

    where is serialization used other than file handling

  • @cristianmanolachi3771
    @cristianmanolachi3771 9 років тому

    Hello i did a game in gameguru but i can*t save it.How can i do a savegame file becasue there are not a fucntion to save the file

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

    Why a dto needs to be serialized??

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

    Thanks dude

  • @addagadavenubabu2558
    @addagadavenubabu2558 6 років тому +1

    Can you please explain about serialization version id it will be better.

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

    This time you haven't explain-
    why we need it ?
    What are is uses ?

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

    amazing

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

    Why (save) is needed?

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

    Why r u change in fos to oos

  • @niallscarlett3442
    @niallscarlett3442 7 років тому +2

    Thank you!

  • @vladeb1104
    @vladeb1104 5 років тому +1

    chyba sam zaczne robić tutoriale, nie wyrabiam już z tym akcentem

  • @dominicxavier5274
    @dominicxavier5274 6 років тому

    what is the diff b/w object serialization and object cloning?

    • @harigoutham7651
      @harigoutham7651 6 років тому +1

      dominic xavier
      Object cloning is creating a copy of an object and you don't store it and use right way in the code .
      Object serialisation is copying and also storing object ( may be in a file or database or over a network ) and then you can retrieve at later point of time . It is not possible in case of cloning

  • @rakshitks7850
    @rakshitks7850 6 років тому

    Exception in thread "main" java.lang.ClassCastException: java.base/java.lang.String cannot be cast to rak
    at Main.main(Main.java:23)
    help me out with @Telusko Learning

    • @JR-mk6ow
      @JR-mk6ow 3 роки тому

      You simply can't convert a string directly to Tak object.
      Try to implement the toString() in the Rak class

  • @prim16
    @prim16 6 років тому +1

    Thank youuuuuuuuu

  • @aidandanielski
    @aidandanielski 7 років тому

    Don't you have to close these files?

  • @yousraahmedd
    @yousraahmedd 4 роки тому

    Thankss!!

  • @ragavendravignesh1028
    @ragavendravignesh1028 6 років тому +1

    The default value for an object is null. But you are mentioning it as 0

    • @_jamesbro_
      @_jamesbro_ 5 років тому

      Integer default is null
      int default is 0

  • @anshuyadav248
    @anshuyadav248 7 років тому

    program show unexpected output like "serialdemo@e9e54ce",serialdemo is name of my serializable class

  • @manavmalhotra8513
    @manavmalhotra8513 4 роки тому

    Why typevasting in save?

  • @neomillmarcreas6535
    @neomillmarcreas6535 5 років тому +4

    The explanation is vague

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

    Need to work on accent perhaps.
    Too fast explanation. Hard to understand words.

  • @DrFlash-mh6st
    @DrFlash-mh6st 2 місяці тому

    So many mistakes in 4 minutes :(

  • @zbigniew463
    @zbigniew463 5 років тому

    I know that you love sound of your voice, but you do the presentation for me, so get to the point, and skip the hay.

  • @anshuyadav248
    @anshuyadav248 7 років тому

    program show unexpected output like "serialdemo@e9e54ce",serialdemo is name of my serializable class

  • @doplerfish
    @doplerfish 8 років тому +1

    Thank you!

  • @anshuyadav248
    @anshuyadav248 7 років тому

    program show unexpected output like "serialdemo@e9e54ce",serialdemo is name of my serializable class

    • @philipvarghese2863
      @philipvarghese2863 7 років тому +1

      +Anshu Yadav I know its too late, anyway when you simply try to display an object it will be in the format "type@address" to represent the object in string we have to override the toString method of Object class. In this case the toString method will be as follow..
      @Override
      public String toString() {
      return "Save [i=" + i + "]";
      }
      Note: it should be implemented in the class Save