https://github.com/nojronatron/java-generics-practice
Follow documented methods to create and utilize generics in Java.
https://github.com/nojronatron/java-generics-practice
generic-types generics java object-oriented-programming
Last synced: about 1 year ago
JSON representation
Follow documented methods to create and utilize generics in Java.
- Host: GitHub
- URL: https://github.com/nojronatron/java-generics-practice
- Owner: nojronatron
- Created: 2023-03-04T05:47:46.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-04T05:50:01.000Z (over 3 years ago)
- Last Synced: 2025-02-08T17:29:20.167Z (over 1 year ago)
- Topics: generic-types, generics, java, object-oriented-programming
- Language: Java
- Homepage:
- Size: 65.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GenericsPractice Project
Following the Oracle Java Docs [Q and E](https://docs.oracle.com/javase/tutorial/java/generics/QandE/generics-questions.html), create code and tests that will validate learnings and answer ending Quiz questions.
## Takeaways
- An array is denoted by `[]` following a Type, which can be any primitive or Class: `Integer[] india = {1,2,3,}` is functionally similar to `int[] india = {1,2,3,}` but probably takes more memory storage.
- The Java class Arrays is a functional class that help work with Array types and Lists.
- The Java class Array has static methods used to create and access Java arrays.
- `List` is a Collection Interface that extends `Iterable`. Brackets `[]` array does not have these interface features.
- `ArrayList` implements `List` and is a fully instantiatable Class. Should not be confused with brackets `[]` arrays.
- Generic functions do *not* require a containing class to be generic! Use `public static void setMethod(){}` to set the method with a generic type placeholder.
- Leveraging wildcard `?` can be tricky due to inheritance, and there are situations where using it will cause problems during run time.
## Resources
Oracle's [Java Tutorials](https://docs.oracle.com/javase/tutorial/java/generics/index.html)
Baeldung: [Java Generics](https://www.baeldung.com/java-generics)
Baeldung: [Comparing Objects in Java](https://www.baeldung.com/java-comparing-objects)