Modeling Entities in Java: Static Members, Arguments, & Method Overriding

Java    |    Expert
  • 14 videos | 2h 6s
  • Includes Assessment
  • Earns a Badge
Rating 4.4 of 38 users Rating 4.4 of 38 users (38)
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 course
    Recall java best practices to access static variables
    Use class references to access static variables and describe the use of the 'final' keyword
    Outline access restrictions on instance members from static members
    Implement a scenario using a static variable to count instantiated objects
    Use class reference to invoke and execute static methods
    Reassign variables inside methods and explore where the changes are visible
  • Contrast the effects of variable reassignment with variable modification
    Outline pass-by-value and pass-by-reference with custom objects
    Recall the operation of the == operator and the default .equals() method
    Examine how to work with the .equals() and .hashcode() methods and the hashcode contract
    Override .equals() to check for semantic equality
    Override .hashcode() and .equals() to honor the hashcode contract
    Summarize the key concepts covered in this course

IN THIS COURSE

  • 2m 35s
    Learn 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 31s
    Learn 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
  • Locked
    3.  Using Static Variables and the final Keyword
    8m 4s
    In 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
  • Locked
    4.  Working with Static and Instance Methods and Fields
    9m 51s
    In 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
  • Locked
    5.  Using a Static Field for Auto-counting Objects
    9m 47s
    In 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
  • Locked
    6.  Using a Class Reference to Invoke Static Methods
    11m 43s
    In 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
  • Locked
    7.  Exploring Field Reassignments
    9m 49s
    In 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
  • Locked
    8.  Understanding Pass-by-Value and Pass-by-Reference
    10m 52s
    In 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
  • Locked
    9.  Pass-by-value/Pass-by-reference with Custom Objects
    4m 54s
    In 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
  • Locked
    10.  Checking Object Equality with == and .equals()
    10m 23s
    In 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
  • Locked
    11.  Understanding the HashCode Contract
    8m 31s
    In 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
  • Locked
    12.  Overriding the .equals() Method
    8m 45s
    In 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
  • Locked
    13.  Overriding the .hashCode() Method
    11m 33s
    In 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
  • Locked
    14.  Course Summary
    2m 50s
    Today, 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.

YOU MIGHT ALSO LIKE

Rating 4.6 of 62 users Rating 4.6 of 62 users (62)
Rating 4.6 of 57 users Rating 4.6 of 57 users (57)
Rating 4.7 of 84 users Rating 4.7 of 84 users (84)

PEOPLE WHO VIEWED THIS ALSO VIEWED THESE

Rating 4.8 of 31 users Rating 4.8 of 31 users (31)
Rating 4.4 of 43 users Rating 4.4 of 43 users (43)
Rating 4.6 of 144 users Rating 4.6 of 144 users (144)