When learning to code in Java, it’s essential to first understand the four principles of object-oriented programming or OOP. Java code consists of classes, which are categories of real-world objects.
Objects themselves are specific instances of a class. OOP permits the interaction of objects through four fundamental principles: encapsulation, inheritance, polymorphism, and abstraction. These principles empower objects to communicate and cooperate, leading to the development of robust and effective applications. Other advantages include faster and easier execution, a clear program structure, adherence to the "Don't Repeat Yourself" (DRY) principle in Java, and enhanced code maintainability, modification, and debugging. Additionally, OOP facilitates the creation of reusable applications with reduced code and shorter development times.Abstraction means to only show the necessary details to the user of the object. For example, if you were creating a video game, you can create separate class, called Enemy and put the details, such as what they say and do, on that page. In the main project page, you can insert the enemy class and the details will not be right there, but they will still be used.
Inheritance enables code reusability. New classes can be created that extends off existing classes, then more can be added. It allows the coder to avoid redundancy in their code and it saves time coding.
Polymorphism is made possible by inheritance. You must extend a class before you change the settings on that new class to fit it. Polymorphism helps determine what kind of function to run while the program is running. You can have two objects doing a type of behavior in a different way simultaneously in a program.
Encapsulation means restricting certain data about an object from the person that is calling that object in the code. For example, someone playing a video game shouldn’t be able to change the health setting of an enemy by being able to access the health property of the enemy object. The code writer sets the properties they don’t want inadvertently altered to private instead of public. Then getters and setters could be implemented to give a user access to what the coder wants them to be able to see in the form of a print and set in the form of changing data.
Tips to help a newbie download and start using Java
I recommend finding out what type of distribution you have for your computer’s Operating System. For example, I knew that I had Linux but did not know it was Debian. This is important so you choose the right software download link. Google what commands to use to look this up.
Refer to the Get Started button on this link to download Java and IDE so you can code in Java. https://docs.oracle.com/javase/tutorial/index.html
This YouTube video helped me tremendously when I first started using Java. It’s specifically for Chromebook so if you have another type of computer, I would search download java + the computer type. https://youtu.be/1ji9jCzGdG8?si=QNF2e6apqWO5du6M
This next video helped me with the IDE, Netbeans. It contains the commands needed to complete. https://youtu.be/JpGxvh_rTHw?si=1aLWj_4D99-tzihG
After everything is downloaded and open, go back to the first link of tutorials and follow the instructions to create the first application Hello World.
No comments:
Post a Comment