Modeling Entities in Java: Static Members, Arguments, & Method Overriding
Java
| Expert
- 14 videos | 2h 6s
- Includes Assessment
- Earns a Badge
The best way to avoid mysterious bugs while running your Java code is to be adept at working with static members, argument passing, and object base class methods. Use this course to master these subtleties: the difference between static and instance variables and methods, the hashCode contract, and how pass-by-value and pass-by-reference semantics play out with argument passing in Java. By the end of this course, you'll be able to model state in classes using both static and instance variables, write methods to avoid unexpected changes in input arguments, and adhere to the hashCode contract so that objects function as expected when placed in common Java containers.
WHAT YOU WILL LEARN
-
Discover the key concepts covered in this courseRecall java best practices to access static variablesUse class references to access static variables and describe the use of the 'final' keywordOutline access restrictions on instance members from static membersImplement a scenario using a static variable to count instantiated objectsUse class reference to invoke and execute static methodsReassign variables inside methods and explore where the changes are visible
-
Contrast the effects of variable reassignment with variable modificationOutline pass-by-value and pass-by-reference with custom objectsRecall the operation of the == operator and the default .equals() methodExamine how to work with the .equals() and .hashcode() methods and the hashcode contractOverride .equals() to check for semantic equalityOverride .hashcode() and .equals() to honor the hashcode contractSummarize the key concepts covered in this course
IN THIS COURSE
-
2m 35sLearn to model entities in Java through static members, arguments, and method overrides. Access static variables, instance methods, and fields. Reassign fields, auto count objects, and apply techniques to pass-by-value, pass-by-reference. Check object equality. Use hash codes. FREE ACCESS
-
10m 31sLearn Java best practices to access static variables, member functions, and methods. Create a public class cookie to track user activity via a browser and study member variables, constructors, and member functions. FREE ACCESS
-
8m 4sIn this video, see how to use class references to access static variables. Explore ways to apply modifiers to member variables and member functions. Discover how to use the 'final' keyword in a cookie class that we create as an exercise. FREE ACCESS
-
9m 51sIn this video, we compare public, private, and protected fields. Explore access restrictions on instance members that come from static members. Troubleshoot problems that happen when a static field is made private. FREE ACCESS
-
9m 47sIn this video, we set up a scenario that uses a static variable to count instantiated objects. For this example, we count cookies with a "for" loop. See how to use java.util.Random to generate and assign pseudorandom, unique IDs for every object in a class. FREE ACCESS
-
11m 43sIn this video, see how to use a class reference to invoke and execute static methods. Discover the relationship between static and non-static methods. Learn that instance methods can invoke static methods, but it is not easy to go in the other direction. FREE ACCESS
-
9m 49sIn this video, learn how to reassign variables inside methods. Discover where the changes are visible. Explore pass-by-value and pass-by-reference semantics. See how primitive types, such as integers and doubles, exhibit pass-by-value semantics, and extend to java.lang.integer and java.lang.double. FREE ACCESS
-
10m 52sIn this video, we will compare the effects of variable reassignment with variable modification. Watch strings work with pass-by-value and pass-by-reference semantics. See how to use Arrays.toString and reassignArray functions. FREE ACCESS
-
4m 54sIn this video, see how to apply pass-by-value and pass-by-reference semantics to custom objects. Observe that if we reassign inside a called method, the reassignment is lost, but if we update inside the called method, those updates are preserved when we come back out. FREE ACCESS
-
10m 23sIn this video, you will learn about the == operator and the default .equals() method. Learn that, in Java, we can override the implementation of the .equals() method, but we cannot change the workings of the double equals operator. FREE ACCESS
-
8m 31sIn this video, we explore how to work with the .equals() and .hashCode() methods and the hashCode contract. We will see that if we try to override the .equals method, we also need to make sure that we follow the hashCode contract. FREE ACCESS
-
8m 45sIn this video, we use override .equals() to check for semantic equality. We learn that the reason we override the .equals() method is to check for semantic equality rather than object identity equality. FREE ACCESS
-
11m 33sIn this video, we see how to override the .hashCode() and .equals() methods, in order to honor the hashCode contract. Learn that anytime you need to override the .equals method, you also need to override the .hashCode method. FREE ACCESS
-
2m 50sToday, you learned to model entities in Java through static members, arguments, and method overrides. Access static variables, instance methods, and fields. Reassign fields, auto count objects, and apply techniques to pass-by-value and pass-by-reference. Check object equality. Use hash codes. FREE ACCESS
EARN A DIGITAL BADGE WHEN YOU COMPLETE THIS COURSE
Skillsoft is providing you the opportunity to earn a digital badge upon successful completion on some of our courses, which can be shared on any social network or business platform.
Digital badges are yours to keep, forever.