+ 3
Difference between class and id
Hello, I want to ask something that confuses me. I'm still confused about the difference between class and id. Can anyone help explain it to me? A code example will really help Sorry for the bad English :( Thanks in advance (Edited)
4 Réponses
+ 7
Imagine a new cell phone. It has a bar code on the box it came with. When you buy the phone, the cashier scans the bar code, and the system finds out what kind of phone it is, the price, and probably some other things too.
It doesn't, however, know exactly what phone it is, from what batch of production it comes from, etc..
Inside the phone is a serial number. This identifies the exact phone, and you can use this information to find info about where and when it was produced, etc. But it won't know the price, or know how many the shop has left of these phones.
Bar codes are classes, serial numbers are id's.
Classes can be used again, id's cannot.
+ 6
The main difference is class is generic (it is to be applied to multiple similar elements)
while id is unique ( only one id once ideally)
https://www.sololearn.com/discuss/1018244/?ref=app
https://www.sololearn.com/discuss/296093/?ref=app
+ 4
This question has been asked and answered before, please use the search bar next time😊
Answers:
https://www.sololearn.com/discuss/706160/?ref=app
https://www.sololearn.com/discuss/519080/?ref=app
https://www.sololearn.com/discuss/91160/?ref=app
https://www.sololearn.com/discuss/401169/?ref=app
https://www.sololearn.com/discuss/1004409/?ref=app
https://www.sololearn.com/discuss/496943/?ref=app
[ Credits: @NezhnyjVampir ]
+ 2
thanks for help :)
really helpful