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.
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...
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
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).
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.
@@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); } }
@@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
@@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
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
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
+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
Very useful lecture for me...Thank you sir, I'm following you from 3 years.
man, thanks for this material, the way you explained, the sequence of each idea was just perfect.
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..
You and Durga sir are wizards in JAVA!!!
Java Brains wants to know your location
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.
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.
Yes thank you CS 101
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...
how to do so?
private static final long serialVersionUID = 4L; insinde the class with implements serialization
best explanation. Thank you
Excellent Example, just Legend!
Super explanation, thanks for your time!
you r my best teacher
Thank you for this very useful video!
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
Thank you Telusko. You are really good teacher.
I always see your tutorials.
in this example are we saving the object over a network???????
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).
such a badass explaination
This is an amazing tutorial, exactly what I was looking for... thanks a lot bro
Thank you... concept got cleared
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.
You are a god.
great tutorial man
Simple + effective
super sir well explained
great video. I just wanted to ask what is the difference between ObjectOutputStream and DataOutputStream?
He haven't closed the objectoutput stream
great video
excellent sessio. one question, will object code also get serialized and deserialized or only variable values?
Can you please explain Serialization with static variables and transient? It will be better.
The best✨
Great tutorial.......Thanks
Awesome video man. Keep it up.
Awesome!!! Thank you!
great video! just what I was looking for
Well done ! Keep on.
Nice workdone .. Thank you...
Thanks,helped a lot
nicely explained.
nice and simple.
Thank you
Is that sir updatable? Like mysql, excel , word ?
does memory is created for obj1 in heap when we say Save obj1 = (Save) ois.readObject();
Obj1=obj will not copy the values
It will copy the reference of obj into obj1
Clear your concepts first
It will copy bro. Just code it and check
@@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);
}
}
@@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
@@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
yeah bro exactly !!!
can we you any marker interface interchangable ,for example instead of serializable can we use clonable interface is it posssible
Thanks dude
How do I find the previous video? 🥺
This time you haven't explain-
why we need it ?
What are is uses ?
amazing
where is serialization used other than file handling
where
Sir in mine.. i can't see my saved file obj.txt..
Actually I searched it. But file is not saved
Why a dto needs to be serialized??
chyba sam zaczne robić tutoriale, nie wyrabiam już z tym akcentem
Thank youuuuuuuuu
Why r u change in fos to oos
Why (save) is needed?
Can you please explain about serialization version id it will be better.
Thankss!!
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
Thank you!
what is the diff b/w object serialization and object cloning?
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
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
You simply can't convert a string directly to Tak object.
Try to implement the toString() in the Rak class
The default value for an object is null. But you are mentioning it as 0
Integer default is null
int default is 0
Don't you have to close these files?
The explanation is vague
program show unexpected output like "serialdemo@e9e54ce",serialdemo is name of my serializable class
Why typevasting in save?
you are explicitly converting it
Need to work on accent perhaps.
Too fast explanation. Hard to understand words.
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.
So many mistakes in 4 minutes :(
Cant understand
Thank you!
program show unexpected output like "serialdemo@e9e54ce",serialdemo is name of my serializable class
program show unexpected output like "serialdemo@e9e54ce",serialdemo is name of my serializable class
+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