Java is considered a object oriented programming language, so it it all about objects. Objects are substances that have "rules" that govern them, and you can create as many of the same object as you want in your program. All of these instances of the object can be manipulated differently, but they all have the same code. In this post, I plan to teach you about objects.
Unlike integers and other primitive data types, objects do not have a limited space that they occupy on the computer. When I was teaching you about integers, I mentioned a bunch of calculations that you can do to those integers. Objects are not like a variable, but more like a physical object. This physical object can have multiple properties that describes how it looks and acts. These properties are like variables that describe the object, so an object could have a variable that describes how tall it is, or how fast it is traveling. Physical objects can also do things like move around and eat stuff. Guess what, you can also make objects in your program do things! To make your object do things, you will need to create and code a method for what you want your object to do.
If you are still not fully understanding how an object works in java, I will give you an example. Lets say that I wanted to make an object that is a sole, I would want to make variables for its height, weight, length, position, speed, how hungry it is, and much more. Some methods that the sole would have would include eating, swimming, sleeping, and hiding.
Hopefully, you now know a little bit more about java, objects, and soles. Thanks for reading!
No comments:
Post a Comment